4 ms·
One note: While using field number for anything is perfecrly valid SQL, this will not pass a code review if I'm the one doing the review. Reason being, it's not
by progre 6y ago
One note: While using field number for anything is perfecrly valid SQL, this will not pass a code review if I'm the one doing the review. Reason being, it's not clear without looking at the field list what is being ordered. For extra shame do something like:
select * from foo order by 2
Order of the fields when doing "select *" may be guaranteed (I don't know) but they have been dependent on when the feild was added to the database on every system I have worked with, and sometimes patches are applied in diffrent orders on diffrent databases.
- plq 6y agoIf you have a Python script create your tables AND 1=1 AND this script has the table information stored in dicts in the {column name: column type} form AND this script is run by a python version where the dict order is undefined you will get funny outputs from your queries that break production deployments in subtle and unique ways. So yeah, just use column names (and name your computed columns!).
- progre 6y agoYes, name your computed columns. Makes your life easier.