clsql: foreign key not saved in database

Discussion of Common Lisp
Post Reply
andrei-n
Posts: 2
Joined: Mon Apr 18, 2016 5:09 am

clsql: foreign key not saved in database

Post by andrei-n » Mon Apr 18, 2016 9:11 am

I'm trying to make a small demo application with orm. I'm using postgresql and clsql with sbcl. When there is one table everything seems to work: I can insert new records and modify them, and also read if I modify the database manually. But when I try to make an object that points to another object and store it like a foreign key (to an existing line in a table), the foreign key is not inserted (I have a null value instead).

I tried to make an example similar to this: http://clsql.kpe.io/manual/def-view-class.html.

Is it possible to do what I'm trying to to with these tools? Do I need to override reader and writer methods to make it work?

Thank you.

robby_dobby
Posts: 1
Joined: Sat May 23, 2015 6:17 am

Re: clsql: foreign key not saved in database

Post by robby_dobby » Wed Apr 20, 2016 3:55 pm

Hello,

I see that nobody replied to your post. From your post, it looks like you have an object hierarchy model that you want persisted into your database. This sounds suspiciously like a problem for ORMs to handle. Have a look at CLIKI - ORM for ORM libraries in CL.

In short, you have two options:
  1. * Straighten out your UPDATE/INSERT queries that they exactly reference the right tables and objects
    * Use an ORM

Post Reply