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

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

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

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

Stefan365 opened this issue Dec 11, 2017 · 14 comments
Assignees
Labels
cat/bug A bug which needs fixing source/qe Raised by QE

Comments

@Stefan365
Copy link

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 A bug which needs fixing label Dec 11, 2017
@KurtStam KurtStam changed the title datamapper SQL parser doesn't recognize parameters for LIKE Database SQL parser doesn't recognize parameters for LIKE Dec 14, 2017
@KurtStam
Copy link
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 Database SQL parser doesn't recognize parameters for LIKE DB Connector SQL parser doesn't recognize parameters for LIKE Dec 14, 2017
@KurtStam KurtStam changed the title DB Connector SQL parser doesn't recognize parameters for LIKE DB Connector: SQL parser doesn't recognize parameters for LIKE Dec 14, 2017
@Stefan365
Copy link
Author

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
Copy link
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%'.

@KurtStam
Copy link
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 pushed a commit to KurtStam/syndesis that referenced this issue Dec 14, 2017
@Stefan365
Copy link
Author

@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
Copy link
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
Copy link
Contributor

KurtStam commented Jan 2, 2018

Please reopen if this is still an issue for you.

@KurtStam KurtStam closed this as completed Jan 2, 2018
@Stefan365
Copy link
Author

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
Copy link
Author

@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
Copy link
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.

@Stefan365
Copy link
Author

@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
Copy link
Contributor

@Stefan365 I added this test back then:

https://github.com/syndesisio/syndesis/blob/master/app/connector/sql/src/test/java/io/syndesis/connector/sql/common/SqlParserTest.java#L148-L155

and it's tested with Oracle, Postgresql, Mysql and Derby.

@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
@heiko-braun heiko-braun added the source/qe Raised by QE label Jul 16, 2018
@KurtStam
Copy link
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 as completed Oct 8, 2018
@Stefan365
Copy link
Author

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
Labels
cat/bug A bug which needs fixing source/qe Raised by QE
Projects
No open projects
Bug Backlog
  
Backlog
QE issues
Backlog
Development

No branches or pull requests

3 participants