On 3 Dec 2015, at 12:49pm, R Smith <rsmith at rsweb.co.za> wrote: > I *ALWAYS* write cross-platform code as far as SQL is concerned. I even think > in this day and age every programmer should, or is there a case for the > opposite?
If cross-platform code worked identically cross-platform I'd rest more easily. The case in question is a good example. Technically if you provide a long string for a SQL column VARCHAR(6) the SQL engine should silently truncate it to 6 characters before storing it. SQL engines which actually support VARCHAR do this correctly. SQLite doesn't. So although your code executes without error messages in both SQLite and PostgreSQL, it will do different things if your software passes along a seven character string. There are numerous other examples of this in SQL, including when constraint checking is done, the results of errors triggering ROLLBACK, how values are sorted if you put numbers into string columns, and how NULLs are handled in sorting and comparisons. There are arguments for and against what you're doing and I don't intend to take a stance. Just to keep readers aware of the problems. Simon.