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

DB Connector: SQL parser doesn't recognize parameters for LIKE #698

Closed
Stefan365 opened this Issue Dec 11, 2017 · 14 comments

Comments

Projects
3 participants
@Stefan365

Stefan365 commented Dec 11, 2017

e.g.
this is ok:

DELETE FROM TODO WHERE task = :#task

but datamapper cannot recognize these parameters:

DELETE FROM TODO WHERE task LIKE ':#task'
DELETE FROM TODO WHERE task LIKE '%:#task%'

@Stefan365 Stefan365 added the cat/bug label Dec 11, 2017

@KurtStam KurtStam changed the title from datamapper SQL parser doesn't recognize parameters for LIKE to Database SQL parser doesn't recognize parameters for LIKE Dec 14, 2017

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Dec 14, 2017

Contributor

I think you got an error? This error should have been shown at the action configuration time (see also #718). So it's nothing to do with the datamapper, but with the DB connector parser instead. That said, will try to fix it.

Contributor

KurtStam commented Dec 14, 2017

I think you got an error? This error should have been shown at the action configuration time (see also #718). So it's nothing to do with the datamapper, but with the DB connector parser instead. That said, will try to fix it.

@KurtStam KurtStam self-assigned this Dec 14, 2017

@KurtStam KurtStam changed the title from Database SQL parser doesn't recognize parameters for LIKE to DB Connector SQL parser doesn't recognize parameters for LIKE Dec 14, 2017

@KurtStam KurtStam changed the title from DB Connector SQL parser doesn't recognize parameters for LIKE to DB Connector: SQL parser doesn't recognize parameters for LIKE Dec 14, 2017

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 Dec 14, 2017

I don't see any error in web console.
It seems parser doesn't have problem with query, but I have problem with the parser.
If I create datamapper step subsequently,
the parameter task has not been recognized (probably because located inside single quotes).
Kindly see attached pictures.
no_quotes
quotes

Stefan365 commented Dec 14, 2017

I don't see any error in web console.
It seems parser doesn't have problem with query, but I have problem with the parser.
If I create datamapper step subsequently,
the parameter task has not been recognized (probably because located inside single quotes).
Kindly see attached pictures.
no_quotes
quotes

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Dec 14, 2017

Contributor

@Stefan365 When fixing this I think your second example is slightly wrong as I think the % sign needs to be part of the input param itself. So as you state in your first example it should be able to handle:

DELETE FROM TODO WHERE task LIKE ':#task'

where the task param value can be set to 'Joe%'.

Contributor

KurtStam commented Dec 14, 2017

@Stefan365 When fixing this I think your second example is slightly wrong as I think the % sign needs to be part of the input param itself. So as you state in your first example it should be able to handle:

DELETE FROM TODO WHERE task LIKE ':#task'

where the task param value can be set to 'Joe%'.

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Dec 14, 2017

Contributor

@Stefan365 as far as your datamapper screenshots, you can only get at the moment because of #718. So now you arrive at the datamapper with an invalid dataShape. You can verify the error in your javascript console when saving the action config (but bc of #718, it keeps going)

Contributor

KurtStam commented Dec 14, 2017

@Stefan365 as far as your datamapper screenshots, you can only get at the moment because of #718. So now you arrive at the datamapper with an invalid dataShape. You can verify the error in your javascript console when saving the action config (but bc of #718, it keeps going)

KurtStam added a commit to KurtStam/syndesis that referenced this issue Dec 14, 2017

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 Dec 14, 2017

@KurtStam this is my result with
DELETE FROM TODO WHERE task LIKE ':#task'
(see picture)
It is not clear to me how to infiltrate '%' in input parameter.
quotes2
e.g. you want to delete all todos which tasks contains first_name (from Contact). how do you proceed?

Stefan365 commented Dec 14, 2017

@KurtStam this is my result with
DELETE FROM TODO WHERE task LIKE ':#task'
(see picture)
It is not clear to me how to infiltrate '%' in input parameter.
quotes2
e.g. you want to delete all todos which tasks contains first_name (from Contact). how do you proceed?

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Dec 14, 2017

Contributor

@Stefan365 Like I said before the inputDataShape was calculated incorrectly. This is what my commit fixes. So with that fix you should be able to issue exactly what you did:
DELETE FROM TODO WHERE task LIKE ':#task'
where you can make task to firstName. I think in the datamapper you maybe able to enhance that value to concatenate it with % signs. I think you can use a padStringLeft and padStringRight in the datamapper. You cannot do it in the query.

Contributor

KurtStam commented Dec 14, 2017

@Stefan365 Like I said before the inputDataShape was calculated incorrectly. This is what my commit fixes. So with that fix you should be able to issue exactly what you did:
DELETE FROM TODO WHERE task LIKE ':#task'
where you can make task to firstName. I think in the datamapper you maybe able to enhance that value to concatenate it with % signs. I think you can use a padStringLeft and padStringRight in the datamapper. You cannot do it in the query.

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Jan 2, 2018

Contributor

Please reopen if this is still an issue for you.

Contributor

KurtStam commented Jan 2, 2018

Please reopen if this is still an issue for you.

@KurtStam KurtStam closed this Jan 2, 2018

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 May 13, 2018

hi @KurtStam ,
I see this behavior again.
if I put e.g. DELETE FROM TODO WHERE task LIKE ':#task' as target connection action.
I don't have option to add Data Mapper step, since ':#task' is not visible for DM. If I change it to :#task, parameter is recognized as should be.

Checked on CR1(see https://gist.github.com/dsimansk/b839cbd39e553ec4680bcd8a3b47c3ff) and Syndesis master branch.

Stefan365 commented May 13, 2018

hi @KurtStam ,
I see this behavior again.
if I put e.g. DELETE FROM TODO WHERE task LIKE ':#task' as target connection action.
I don't have option to add Data Mapper step, since ':#task' is not visible for DM. If I change it to :#task, parameter is recognized as should be.

Checked on CR1(see https://gist.github.com/dsimansk/b839cbd39e553ec4680bcd8a3b47c3ff) and Syndesis master branch.

@Stefan365 Stefan365 reopened this May 13, 2018

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 May 13, 2018

@KurtStam one more thing,
IMHO If I look at ... LIKE '%:#param'... vs. ... LIKE ':#param' + padStringLeft '%' in datamapper
I'm finding first option more user friendly than the second one (as a user how should I know, there is some 'padStringLeft' option in DM? moreover if I'm familiar with SQL regex)

Is there any possibility to allow " '%:#param' syntax" in the future?

Stefan365 commented May 13, 2018

@KurtStam one more thing,
IMHO If I look at ... LIKE '%:#param'... vs. ... LIKE ':#param' + padStringLeft '%' in datamapper
I'm finding first option more user friendly than the second one (as a user how should I know, there is some 'padStringLeft' option in DM? moreover if I'm familiar with SQL regex)

Is there any possibility to allow " '%:#param' syntax" in the future?

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam May 15, 2018

Contributor

@Stefan365 You're right, I mistyped above, there are not supposed to be any quotes.

At the moment finding a parameter relies on the fact that it starts with :#. So if we use a prefix % we're mixing a variable name with SQL syntax. Not sure Camel itself even supports that. That said I'm sure we can sort of 'preprocess' the statement if we really want to support it, but it's not that easy.

Contributor

KurtStam commented May 15, 2018

@Stefan365 You're right, I mistyped above, there are not supposed to be any quotes.

At the moment finding a parameter relies on the fact that it starts with :#. So if we use a prefix % we're mixing a variable name with SQL syntax. Not sure Camel itself even supports that. That said I'm sure we can sort of 'preprocess' the statement if we really want to support it, but it's not that easy.

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 May 16, 2018

@KurtStam In that case (no quotes only) LIKE cannot be used at all.
Just one question, did it never work? I'm quite sure it worked (LIKE ':#param') for some time period.

Stefan365 commented May 16, 2018

@KurtStam In that case (no quotes only) LIKE cannot be used at all.
Just one question, did it never work? I'm quite sure it worked (LIKE ':#param') for some time period.

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam
Contributor

KurtStam commented May 16, 2018

@heiko-braun heiko-braun added this to Backlog in Bug Backlog Jun 23, 2018

@heiko-braun heiko-braun added this to Backlog in QE issues Jul 16, 2018

@KurtStam

This comment has been minimized.

Show comment
Hide comment
@KurtStam

KurtStam Oct 8, 2018

Contributor

@Stefan365 I would say that if the Camel SQL component starts supporting it, then we should add support for it too. Can you open a ticket with the Camel project?

Contributor

KurtStam commented Oct 8, 2018

@Stefan365 I would say that if the Camel SQL component starts supporting it, then we should add support for it too. Can you open a ticket with the Camel project?

@KurtStam KurtStam closed this Oct 8, 2018

@Stefan365

This comment has been minimized.

Show comment
Hide comment
@Stefan365

Stefan365 Oct 8, 2018

hi @KurtStam since July I don't work for RedHat, contact please someone else from syndesis-qe team.

Stefan365 commented Oct 8, 2018

hi @KurtStam since July I don't work for RedHat, contact please someone else from syndesis-qe team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment