Decimal / Numeric datatypes

Forum for posting problems using QxEntityEditor

Decimal / Numeric datatypes

Postby doulos » Mon Aug 18, 2014 1:27 pm

Hello,

I am trying to create a model for my application which will also contain currency values. In order to handle these correctly (IEEE 754 conformant), I need sto store them in the database as SQL type NUMERIC(10,2), and map them to appropriate C++ classes (I chose QDecNumer from the QDecimal library). I have found information in the FAQ that seems to explain how to introduce such new types, but I would also like to be able to maintain the model in QxEntityEditor, such that I can create columns with type QDecNumber, which would correctly map to NUMERIC columns (e.g., in the generated DDL)

Can someone point me to the required information for doing this, or provide it directly?

thanks,
chris
doulos
 
Posts: 15
Joined: Mon Aug 11, 2014 1:24 pm

Re: Decimal / Numeric datatypes

Postby qxorm » Mon Aug 18, 2014 7:19 pm

Hello,

To register your QDecNumber class as a persistable type, in your source code, you have to follow this post in the FAQ : http://www.qxorm.com/qxorm_en/faq.html#faq_180
So you have to implement the boost serialization save()/load() functions + implement the functions QxStringCvt_ToVariant()/QxStringCvt_FromVariant().

Then, in QxEntityEditor application, you can use your custom type for properties types (If it is not in the list of types, you can write manually your own type).
Then, in the settings of the DDL SQL plugin, you can map C++ types with database types : there is no constraint so you can map your own type too !

Please let me know if you have any problem or if you want more details.
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Decimal / Numeric datatypes

Postby doulos » Wed Aug 20, 2014 8:14 am

Hello,

thanks for the answer. However, I sure would appreciate a little more detail:

- re. save/load and to/fromVariant functions: where would I implement those? In a header file? Included from where?
- re. EntityEditor: can it be extended to also generate the appropriate #includes for the custom type, so that it is immediately compilable?
- could you elaborate a little more on the DDL SQL plugin settings? Where are they maintained?

thanks a lot,
Christian
doulos
 
Posts: 15
Joined: Mon Aug 11, 2014 1:24 pm

Re: Decimal / Numeric datatypes

Postby qxorm » Wed Aug 20, 2014 12:19 pm

re. save/load and to/fromVariant functions: where would I implement those? In a header file? Included from where?

Yes, implement these functions in your own header file.
Then, include your header file in the generated custom precompiled header file (see ./custom/ directory after the C++ export process, there is a precompiled_header file where you can put what you want).

re. EntityEditor: can it be extended to also generate the appropriate #includes for the custom type, so that it is immediately compilable?

If you include your save/load and to/fromVariant functions in the custom precompiled header file, your project will compile and build without any problem and without adding anything else !

could you elaborate a little more on the DDL SQL plugin settings? Where are they maintained?

Just open QxEntityEditor, open your project, then go to the main menu "Tools >> Export to DDL SQL script file (settings)".
Then, in the settings screen, there is a section named "Mapping C++ type to database SQL type" : this is an editable list where you can map C++ type to SQL type.
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxEntityEditor - Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron