JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 21 forks source link

Order of columns appears to be in a different order on re-generation #11

Closed Jmaharman closed 2 years ago

Jmaharman commented 2 years ago

Hi Jordan,

I've had this issue fairly early on in trying out SqlHydra, when I've looked into the source previously I thought I'd seen the columns being ordered alphabetically before being generated and assumed it was my older version of the tool. However upon generation this time I've got them in a different order now, using SqlHydra 0.503.0.0 with SQL Server.

I was jumping in to take a look and noticed when looking through SqlServerSchemaProvider.fs I can't see any ordering, or have I missed it? That then got me thinking as to what the correct behaviour should be, is it alphabetical, or should it be the order the table has the columns?

Jmaharman commented 2 years ago

FYI I've not changed the table that has been re-ordered, but I have done recent backups etc, so wonder if those transactions affect the ordering. I can investigate further soon, but wondered what your thoughts were on the order.

JordanMarr commented 2 years ago

Hi John!

MargaretKrutikova has an open PR where she is sorting the columns by "ORDINAL_POSITION" for Postgres.

It looks like SQL Server has this same field, so we should definitely do the same there.

Jmaharman commented 2 years ago

I've started setting up the containers so I can run the tests. Due to no experience with devcontainers it took me a while to get it running and the install.sh run. I got there eventually, however when I cd into "src/Tests" and run "dotnet run" I get the following:

vscode ➜ /workspace/src/tests (main ✗) $ dotnet run /usr/share/dotnet/sdk/5.0.402/Microsoft.Common.CurrentVersion.targets(4679,5): error MSB3021: Unable to copy file "/home/vscode/.nuget/packages/microsoft.build.framework/16.11.0/lib/netstandard2.0/Microsoft.Build.Framework.dll" to "bin/Debug/net5.0/Microsoft.Build.Framework.dll". Access to the path is denied. [/workspace/src/SqlHydra.Sqlite/SqlHydra.Sqlite.fsproj]

Is this how you run the tests, or am I doing something wrong?

JordanMarr commented 2 years ago

I have had the exact same issue. It happens when I have previously built the sln locally before opening in the devcontainer.

The solution I have a found is to delete all the obj and bin folders on my local pc. Once those are cleared, you should be able to call dotnet run from the src/Tests.

I should probably add a troubleshooting section for this.

JordanMarr commented 2 years ago

I have created a Contributing Wiki Page and added this issue.

Jmaharman commented 2 years ago

Thanks Jordan