fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
578 stars 146 forks source link

Individuals field doesn't get serialized when saving the context on SQLite #770

Closed OnurGumus closed 9 months ago

OnurGumus commented 1 year ago

Describe the bug When context schema is generated, the individuals field doesn't get serialize even before hand I access to some individuals on the code

To Reproduce Steps to reproduce the behavior:

I access to some individuals data as in

let offsetCount =   ctx.Main.Offsets.Individuals.Visitors.OffsetCount

Right after that

I do create the schema by typing

 ctx.``Design Time Commands``.SaveContextSchema.``Saved /Users/onur/Repos/BinPacker/src/Query/../Server/Database/Schema.sqlite at 05:03:08``

Then I can see the schema file is created all the details except the individuals field is empty.

image

Expected behavior I would expect individuals field to be filled

Desktop (please complete the following information):

Using Latest SqlProvider against SQLite on .NET 6.0.400 SDK

OnurGumus commented 1 year ago

Hello @Thorium, is this known to be working or any directions? Otherwise this effectively makes individuals useless.

Thorium commented 1 year ago

hi, it's not currently supported but I'd guess it would be a nice little addition to save those to the schema

OnurGumus commented 1 year ago

Thanks for the response. When I look at the code here https://github.com/fsprojects/SQLProvider/blob/cc1275f26ba689b1901ae0cee9661612a116050d/src/SQLProvider.DesignTime/SqlDesignTime.fs#L201

Individuals appear to be added to the schema cache. I wonder what prevents them to be serialized.

Thorium commented 11 months ago

Fixed, however I'm not very happy that Individuals combined with SchemaContextPath may save some sensitive data to un-encrypted JSON file, if someone develops against a production database. Luckily many ifs and Individuals are erased with compile time.

The other problem is that schema file may grow fast, because it's loading on "Individuals" call the first X items from that table, not only the used item. I dropped the default 1000 to 50, but it's a parameter so if you want huge schemas you can.

OnurGumus commented 10 months ago

oh I need to test this immediately :) awesome and your points are valid. Will give feedback

OnurGumus commented 9 months ago

Tested and works great, thanks!