demetrixbio / FSharp.Data.Npgsql

F# type providers to support statically typed access to input parameters and result set of sql statement in idiomatic F# way. Data modifications via statically typed tables.
Apache License 2.0
128 stars 15 forks source link

Column name aliases casing is not preserved on generated types #109

Open xperiandri opened 1 year ago

xperiandri commented 1 year ago

Having

SELECT
    used.customer_id AS CustomerId
   ,CASE WHEN configured.customer_id IS NULL THEN 0 ELSE 1 END AS IsConfigured
FROM (SELECT DISTINCT tenant_id FROM a) AS used
LEFT JOIN (SELECT DISTINCT customer_id FROM c) AS configured
ON used.customer_id = configured.customer_id

I get a row with customerid and isconfigured properties instead of CustomerId and IsConfigured

daz10000 commented 1 year ago

I'd have to double check the code, but in general, the provider is opinionated on case for generated fields because postgres in general doesn't handle uppercase gracefully - here's a small example. Though it's against dotnet style guidelines, the provider generates lowercase names to stay consistent with postgres internals which prefer lowercase (it's basically staying away from pain on the SQL side). So in summary, I think this is working as intended, and I wouldn't recommend trying uppercase in column/table names in postgres. Does that make sense?

xperiandri commented 1 year ago

No, because I use aliases. About column names and other internals I agree. But about aliases I disagree