Comments (7)
While I am a big fan of enum in C++, I agree with this: http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/
Anyway: As far as I can tell, set and enum are basically strings. You could therefore simply map enum and set to text. Right?
from sqlpp11-connector-mysql.
enum can be bad, but I've seen a lot of usage for it in a huge production systems (online ads, antifraud etc), and it's as good as a raw C pointer* is bad. You have to control them and you can't ignore them (because someone uses them)
set and enum are almost like strings, but mysql (and, I suppose other rdbms) treat enums/sets like named bitmask - you can do bit operations on them and sometimes it's really helpful.
For the current time it's a good enough solution to treat enum/set as text, better - treat them like flags (or native c++ enums), but sooner ddl enums work with ddl2cpp script the better.
from sqlpp11-connector-mysql.
(note) enums are much faster then text/varchar, they do a great deal of help to constraint a value, but they can be a pain in the ass to alter.
from sqlpp11-connector-mysql.
speaking of this article:
imagine: you have about ~100 databases (it's a long running business), they MUST be fast enough. Aslo you have issues with replication and foreign keys (which are pain in the ass too), and you have about ~300 database servers .
And you have your team. Human factor. Someone sends trash to a field value... bad. Daemons go segfault etc. Enum prevents this.
In the end it's a question of balance between human factor, database architecture, scale and programming guidelines, but it's all we have as always... so - enums are frequent in the wild. Someone has to tame them.
from sqlpp11-connector-mysql.
I won't argue against you using enum :-)
I added enum and set (mapping them to text for now). If you make heavy use of enums and would rather like to map them to C++ enums, I'd be grateful if you could add such a mapping. Take a look at the other datatypes in sqlpp11/data_types. They are not hard to implement. The hardest part (I guess) will be to link column to enum type and string to enum value. I guess you will have to put that into the column spec.
Let me know if you want to try and/or need help with that.
from sqlpp11-connector-mysql.
thanks, I'll close this issue after some testing. (And in the future I'll try to add some datatypes myself before raising an issue)
from sqlpp11-connector-mysql.
Looking forward to those new datatypes!
from sqlpp11-connector-mysql.
Related Issues (20)
- Data is truncated with MariaDB Connector/C 3.0.1+ HOT 11
- Selecting a datetime field always returns epoch HOT 2
- Microseconds ignored when selecting datetime column HOT 1
- Mac osX build HOT 8
- Crash of queries due to MYSQL_RES that is NULL HOT 7
- mysql replace into command HOT 5
- how to use unhex function ,could you give some info? HOT 1
- database name not used HOT 2
- sample code does not work on windows HOT 1
- Can't build DLL on windows HOT 2
- {char,bind}_result_t.size() is unimplemented HOT 5
- How to create mysql::connection without config HOT 2
- TLS/SSL connection is unsupported HOT 1
- Does sqlpp11 support a connection pool? What do I need to do? HOT 2
- How to return mysql auto incorrect when inserting a record in the table? HOT 2
- how can I set mysql options HOT 1
- Error reported while installing sqlpp11-mysql HOT 4
- Why is it necessary to pass database parameter when creating a connection? HOT 3
- Error when compiling HOT 5
- build failed on linux HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlpp11-connector-mysql.