Re: 0/1 vs true/false
От | Greg Stark |
---|---|
Тема | Re: 0/1 vs true/false |
Дата | |
Msg-id | 877k68r261.fsf@stark.dyndns.tv обсуждение исходный текст |
Ответ на | Re: 0/1 vs true/false (Franco Bruno Borghesi <franco@akyasociados.com.ar>) |
Список | pgsql-general |
Franco Bruno Borghesi <franco@akyasociados.com.ar> writes: > This makes me wonder, what about 't' and 'f'?... will they disappear in > newer versions of postgreSQL? Nothing to do with the spec, but can I toss one comment in here: Having booleans printed as 't' and 'f' is the single most annoying thing in all of postgres. I swear it has caused more bugs in my code than any single factor. The problem is that any language driver that just treats all columns as text -- which is presumably most if not all -- will receive the column as 't' and 'f'. Both of which evaluate to true in virtually every language. If it printed booleans as 0 and 1 then pretty much every language would be able to interpret them properly. Instead I have to have =='f' and =='t' strewn throughout my code everywhere making it harder to read and extremely fragile. If I forget one anywhere I silently get subtly broken semantics. This problem might be reduced with the binary protocol since the language drivers will be able to ship boolean values in binary format and allocate variables of the appropriate type in the language. But still a lot of drivers will just bind everything as text anyways, and the goal when casting values to text should be to pick values that get interpreted appropriately. -- greg
В списке pgsql-general по дате отправления: