Table with keyword as its name

Use this forum to request new features or suggest modifications to existing features

Re: Table with keyword as its name

Postby qxorm » Wed Jun 06, 2018 6:35 pm

as I'm concurrently connecting to MSSQL and MySQL databases on various threads ... change to associate these settings per sql generator rather than globally?

For now, you can't specify different SQL generators : it is the same in all the application.
What you can do is just specify your own database connexion before calling a query.

I think that this kind of API could be implemented quite easily : in singleton class qx:QxSqlDatabase which store global settings :

1- for all setXXX() methods, add an optional parameter : bool bJustForCurrentThread, for example :
Code: Select all
void setSqlDelimiterForTableName(const QStringList & lst, bool bJustForCurrentThread = false);


2- for all getXXX() methods, we keep current definition, so :
* it gets setting defined in the thread if it exists,
* Otherwise, it gets setting defined at global level.

What do you think with this API ?
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Re: Table with keyword as its name

Postby JonCat » Thu Jun 07, 2018 6:36 am

I should add that occasionally a thread may get reused for either type of database (or even SQLite in some cases)...!

Ideally we should have the ability to set many of the options found in the QxSqlDatabase singleton at the database type level rather than globally, or per thread, to take into account differences in behaviour and configuration of servers. I'm unsure of the best way of identifying this within qxorm given the information you will have available?
Perhaps some information that is found within the QSqlDatabase in use for the current query would be best? Either QSqlDatabase::driverName() or QSqlDatabase::databaseName() as a key into a map of database specific options, and fall back to the singleton options if they aren't defined?

I really appreciate all your work - I'm aware the above suggestion is an incredibly invasive change!
JonCat
 
Posts: 9
Joined: Tue May 29, 2018 7:31 am

Re: Table with keyword as its name

Postby qxorm » Thu Jun 07, 2018 6:39 pm

at the database type level rather than globally, or per thread

Here is a new version which implements 3 levels of settings (global >> per thread >> per database) : https://www.qxorm.com/version/QxOrm_1.4.5_BETA_19.zip

All setXXX() methods in qx::QxSqlDatabase class have now 2 optional parameters, for example :
Code: Select all
void setSqlDelimiterForTableName(const QStringList & lst, bool bJustForCurrentThread = false, QSqlDatabase * pJustForThisDatabase = NULL);


I didn't test it very much so please let me know if it is working fine.

I really appreciate all your work

Thx !
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Re: Table with keyword as its name

Postby qxorm » Fri Jun 08, 2018 11:40 am

I changed a bit the implementation (it doesn't change the API) + do some optimizations, so here is a new version : https://www.qxorm.com/version/QxOrm_1.4.5_BETA_21.zip
Please let me know if it is working fine.
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Re: Table with keyword as its name

Postby JonCat » Tue Jun 12, 2018 11:49 am

Seems to be working smoothly so far! Thanks!
JonCat
 
Posts: 9
Joined: Tue May 29, 2018 7:31 am

Re: Table with keyword as its name

Postby qxorm » Wed Jun 13, 2018 4:22 pm

Seems to be working smoothly so far! Thanks!

Great !
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Re: Table with keyword as its name

Postby jimmytaker » Thu Aug 16, 2018 7:03 am

A small issue with this is still present. Executing the following:
Code: Select all
   QxSqlDatabase::getSingleton()->setDriverName(QStringLiteral("QSQLITE"), true);
        QxSqlDatabase::getSingleton()->setDatabaseName("db.db3", true);
        QxSqlDatabase::getDatabase().open(); //error assert fails


The assert fails here:
Code: Select all
QSqlDatabase QxSqlDatabase::QxSqlDatabaseImpl::getDatabaseByCurrThreadId(QSqlError & dbError)
        if (! isValid())


And this is ofc because after passing "true" for this thread only both m_sDriverName and m_sDatabaseName are empty in:
Code: Select all
bool isValid() const { return (! m_sDriverName.isEmpty() && ! m_sDatabaseName.isEmpty()); }
jimmytaker
 
Posts: 19
Joined: Fri Dec 23, 2016 11:04 pm

Re: Table with keyword as its name

Postby qxorm » Mon Aug 20, 2018 9:32 am

this is ofc because after passing "true" for this thread only both m_sDriverName and m_sDatabaseName are empty in

Yes you are right : there is a small issue with isValid() : the workaround is to define a global setting (not per thread setting) for DriverName and DatabaseName.
I will fix it before releasing the new version.
Thx !
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Previous

Return to QxOrm - Feature request

Who is online

Users browsing this forum: No registered users and 1 guest

cron