JasperFx / weasel

Database Development Made Easy for .Net
MIT License
65 stars 19 forks source link

Inconsistent handling of upper-cased sequences #100

Closed GeoJGH closed 8 months ago

GeoJGH commented 9 months ago

If someone use a sequence name containing an upper case letter, he will be able to run its app once and query the sequence successfully but it will fail on the next app launch.

Code to create the sequence does not add double quotes, so the identifier is converted to lower case. When you query the nextval, the identifier is also not double-quoted so its lower case version is used and the sequence returns the desired value.

Next time you run your app, the code that looks if the sequence exists or not uses the identifier as-is, so containing an upper-case. There is no sequence under that name so the sequence is created again, using again the lower-cased name, which already exists.

Solutions: 1) always double quote the sequence name 2) or lower-case the sequence name when looking if it already exists

PS: as reported in this stackoverflow post

oskardudycz commented 8 months ago

@GeoJGH, I added a solution for that in https://github.com/JasperFx/weasel/pull/103 and released in 6.2.0

It should work now if you set PostgresqlProvider.Instance.UseCaseSensitiveQualifiedNames to true