sqlite3-ruby icon indicating copy to clipboard operation
sqlite3-ruby copied to clipboard

How could I extend this method?

Open walterdavis opened this issue 6 years ago • 2 comments

https://github.com/sparklemotion/sqlite3-ruby/blob/b6a9d731c2004d96e6b458c661d156b6a94a4f58/lib/sqlite3/translator.rb#L94-L104

I'd like to be able to add new synonyms for "false" here, so that I could support a legacy data structure that insists on using 'Y' and 'N'.

walterdavis avatar Sep 25 '19 19:09 walterdavis

The code as written should work for your use case: "N" will match the last comparison so the result will be false, "Y" won't match anything so will be true. Have you tried it?

seanohalpin avatar Oct 07 '19 21:10 seanohalpin

Yes, I can see that would work. But in my case, I really need the result (in the database) to be capital Y or capital N, because the SQLite version is just a test double for an Oracle version, where those two characters are the only allowed values at the SQL level. I've had to settle for a one-character string field without any sort of type-mapping (it doesn't "know" it's a boolean) and that means that any of my affordances for asserting that it's true or false have to be hand-built.

walterdavis avatar Oct 08 '19 13:10 walterdavis

Hi @walterdavis, sorry I haven't commented on this. We actually removed the translator code in preparation for the 2.0.0 release, so my recommendation to you is to make a proxy object for the result set that does any translation you need.

Sorry about that, and thanks for understanding 🙇

tenderlove avatar Jan 24 '24 22:01 tenderlove