Giter Club home page Giter Club logo

Comments (7)

rbock avatar rbock commented on July 21, 2024

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.

digitalist avatar digitalist commented on July 21, 2024

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.

digitalist avatar digitalist commented on July 21, 2024

(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.

digitalist avatar digitalist commented on July 21, 2024

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.

rbock avatar rbock commented on July 21, 2024

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.

digitalist avatar digitalist commented on July 21, 2024

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.

rbock avatar rbock commented on July 21, 2024

Looking forward to those new datatypes!

from sqlpp11-connector-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.