eudoxia0 / crane

An ORM for Common Lisp.
http://eudoxia.me/crane/
201 stars 19 forks source link

defining tables with :database specified doesn't work #33

Closed fisxoj closed 8 years ago

fisxoj commented 9 years ago

For some reason, it seems like forms like

(deftable thing ()
  (name :type string)
  (:database :thing-db))

Don't evaluate successfully. This is because in meta.lisp the database slot of the <table-class> is a list with the keyword as its only element. All the calls that use table-database to look up the correct db get that list instead of the keyword and then things error.

The fix for me seems to be replacing

(defmethod table-database ((class <table-class>))
  "The database this class belongs to."
  (aif (%table-database class)
       it
       crane.connect:*default-db*))

with

(defmethod table-database ((class <table-class>))
  "The database this class belongs to."
  (aif (%table-database class)
       (car it)
       crane.connect:*default-db*))

I'm not exactly sure what part of this should be considered broken, or if I'm specifying the database option incorrectly, so I'll put this here for @eudoxia0 to decide.

eudoxia0 commented 9 years ago

Being able to choose a name for databases is tricky, because when writing a query by hand with sxql, you have to remember to use the database's custom name instead of its symbol name, which is a pain.

Of course, the problem with this is the SxQLized names are quoted strings, so when writing raw SQL on the shell, e.g. psql, a simple SELECT FROM users becomes SELECT FROM "users".

I'm thinking about disabling this option and just using the SxQLized name.

eudoxia0 commented 8 years ago

For the rewritten version I'm going to disable this option, since there's no real way to tell SxQL to map table names to Crane's table names.

fisxoj commented 8 years ago

Oooh. Can't wait to see the rewrite!

On Thu, Jan 7, 2016, 6:45 PM Fernando Borretti notifications@github.com wrote:

Closed #33 https://github.com/eudoxia0/crane/issues/33.

— Reply to this email directly or view it on GitHub https://github.com/eudoxia0/crane/issues/33#event-508874903.

eudoxia0 commented 8 years ago

It's gonna have 140% the lispyness and 200% more CLOS.