Reputation: 46366
I have a DataImportHandler for importing data from a SQL database. The root entity, Foo
has many Bar
s. The Bar
table uses Foo.Name
as its foreign key. Some Foo names have single quotes in them--such as STW's
.
The import query for the Bar
entity is something like:
select name from Bar where Foo_Name = ${Foo.Name}
However, when Foo.Name contains a single quote the import fails with a SQL exception of Incorrect syntax near 's
.
I've tried wrapping the parameter with escapeSql(${Foo.Name})
but it doesn't appear to be called--the sql being executed is where Foo_Name = 'escapeSql(STW's)'
How do I properly escape the Foo.Name
to avoid issues when they contain single-quotes?
Upvotes: 1
Views: 1555
Reputation: 20270
I think the correct syntax is:
Foo_Name = '${escapeSql(Foo.Name)}'
since escapeSql
is a solr function and not a normal sql function.
Upvotes: 2