Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT Operator #78

Open
gianks opened this issue Nov 16, 2022 · 4 comments
Open

NOT Operator #78

gianks opened this issue Nov 16, 2022 · 4 comments

Comments

@gianks
Copy link

gianks commented Nov 16, 2022

Hi,
sorry if I am missing something here but i could not find any reference to the NOT operator for composing queries.
References:

Is there a reason why it's not implemented (or maybe not documented)?

Thanks a lot

@QxOrm
Copy link
Owner

QxOrm commented Nov 18, 2022

Hello,

There are several NOT methods in the qx:QxSqlQuery class :

- virtual QxSqlQuery & notLike(const QString & val);
- virtual QxSqlQuery & isNotEqualTo(const QVariant & val);
- virtual QxSqlQuery & notIn(const QVariantList & values);
- virtual QxSqlQuery & notIn_Select(const QxSqlQuery & query);
- virtual QxSqlQuery & isNotEqualTo_Select(const QxSqlQuery & query);
- virtual QxSqlQuery & isNotNull();
- virtual QxSqlQuery & isNotBetween(const QVariant & val1, const QVariant & val2);

And if something is missing, you can add custom SQL with :
virtual QxSqlQuery & freeText(const QString & text, const QVariantList & values = QVariantList());

Is there something missing for you ?

@gianks
Copy link
Author

gianks commented Nov 18, 2022

Hello,
I've looked a little more into the issue and realized that the way queries are build require the NOT operator to be built in every possible command, as you suggested.

What about:

- virtual QxSqlQuery & and_not(const QString & val);
- virtual QxSqlQuery & and_not_OpenParenthesis(const QString & val);
- virtual QxSqlQuery & or_not(const QString & val);
- ...

Could you please evaluate to add such methods to allow arbitrary usage of the not operator as you did already for the methods you suggested?

Otherwise you could add generic methods as:
- virtual QxSqlQuery & not(const QString & val);
- virtual QxSqlQuery & not_OpenParenthesis(const QString & val);

But then QxOrm shall also allow the usage of and/or/in/etc. without a parameter, as such:
query.and().not("COL").isWhatever()...

Just proposals, not sure about complexity.
To be clear i could still find my way around this limitation but forced me to rewrite some queries from a more "human readable" form to a equally working and yet less understandable version.

@QxOrm
Copy link
Owner

QxOrm commented Nov 23, 2022

If you try : qx::QxSqlQuery::freeText("NOT") : does it work for you for all your cases ?
Because in this case, I can just add a "not()" method which just calls freeText("NOT").

@gianks
Copy link
Author

gianks commented Nov 23, 2022

I'll give it a try, it might work, I am not sure it will suffice in all cases but let me see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants