Open Krzmbrzl opened 2 years ago
I'm more or less certain that it was a deliberate choice and while I am not sure about why exactly it was done (that would be the question for @msobczak), I'd hazard a guess and say that this is due to the fact that there was historically no obviously appropriate corresponding SQL type for bool
: people stored it as 0/1 number of Y/N chars and probably in other ways too. I'm not even sure if BOOLEAN
type is widely available now, 15 years later -- apparently SQL Server still doesn't have it and you're supposed to use BIT
with it.
Anyhow, we could add support for bool
but it wouldn't as simple as just adding a specialization for it because support for actually reading/writing it from/to the database would need to be added too.
Indeed, a BOOLEAN
data type does not exist in most databases. However, I think the mapping to and from a numeric value that is then used in the SQL should be easy enough.
I might give a shot at implementing this, if you don't mind. Any pitfalls that I should be aware of?
I think this should be relatively straightforward if we decide on using a fixed type for each database (rather than providing some way to choose between the different mappings). But I could be missing something, often problems only become apparent when you start actually implementing things...
Good luck!
Okay, turns out that this seems to be a lot more complicated that I expected it to be. And since I can't find any documentation on the internal workings (am I missing something?), I don't feel like navigating this template jungle :sweat_smile:
I am using a query of the form
which results in a compilation error like this:
Inspecting
exchange_traits.h
it seems there are explicit template specializations for most common types (int, double, string, etc.) but not forbool
.Changing the type of
flag
in my example above fixes the issue, so this appears as if the culprit is that there is no specialization for bool available. Was this a deliberate choice? If so: why?If not, I think it would be quite handy to add a specialization for bool as I would expect this to be a somewhat common datatype for people to use and thus being able to bind into it, would be great.