Mapper generates invalid SQL for Postgres

22 views
Skip to first unread message

sebastian....@gmail.com

unread,
Jul 28, 2017, 3:28:04 PM7/28/17
to Lift
Hi,
i am currently toying around with Lift and Postgres and have the Mapper creating bogus SQL on me.

The whole thing is rather simple. Scala code is not more than:


val thing
= new Thing
    thing
.save()

The model includes only a MappedString and extends a trait with some additional columns (trying to implement a nested set).

The generated SQL happily crashes the app.

Generated SQL Looks like

INSERT INTO thing (entrytext,layout,lft,pagetype,parentid,rgt,title) VALUES ("",0,1,0,1,2,"") RETURNING id

Which causes a "zero-length delimited identifier" error.

Looks like the mapper is generating double quoted strings while postgres requires them to be single quotes.
This does not matter as long those wrongly quoted strings are not the first and last elements in the VALUES block so it will run if the order is different (go figure...).
The query works if those quotes are changed to single ones.

Is this an issue of mapper or jdbc?

And more importantly, how do i change the strings to be single quoted?

I am using lift 3.1.0

And

"org.postgresql"    % "postgresql"          % "9.4-1200-jdbc41"

Best regards

sebastian....@gmail.com

unread,
Jul 31, 2017, 11:30:05 AM7/31/17
to Lift

Well i sort of found the problem.
First of all the double quotes seem do be generated by the logger.
It is rather confusing for a logger to log not the SQL it is actually generating ;)

The crash was caused by DB.runQuery with some broken query which for whatever reason did not get logged.
Recompiling everything made it work.

Best regards

Diego Medina

unread,
Jul 31, 2017, 11:42:44 AM7/31/17
to Lift
Thanks for posting the follow up

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Matt Farmer

unread,
Jul 31, 2017, 12:53:12 PM7/31/17
to Lift
Yeah thanks for tracking this down. Good read! :)

On Mon, Jul 31, 2017 at 11:42 AM Diego Medina <di...@fmpwizard.com> wrote:
Thanks for posting the follow up
On Mon, Jul 31, 2017 at 11:30 AM, <sebastian....@gmail.com> wrote:

Well i sort of found the problem.
First of all the double quotes seem do be generated by the logger.
It is rather confusing for a logger to log not the SQL it is actually generating ;)

The crash was caused by DB.runQuery with some broken query which for whatever reason did not get logged.
Recompiling everything made it work.

Best regards

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages