Hi,
I'm attaching a patch that allows to add table extra options ( :check :unique ..) to a DAO definition.
Sample:
(defclass account () ((id :col-type serial ) (login :col-type (varchar 255) :accessor login :initarg :login) (password :col-type (varchar 255) :accessor password :initarg :password) (created_at :col-type timestamp :accessor created-at :initform (now-timestamp))) (:unique name) (:metaclass dao-class) (:keys id) (:extra-options (:unique login)) (:table-name account.account))
Hi Rafal,
Thanks for the patch. I don't have time to look at it right now but I'll get back to you in a week or so. Chances are, though, that I won't be including it as is. Did you ever use Postmodern before version 1.10? The deftable form I had was going in this same direction, but it became a mess, so I decided to separate the 'class definition' part form the 'table definition' part. A feature similar to your patch that I have been thinking about including is to add something specifically for adding extra indices, sequences, and constraints to a table -- I'm already using something like it in all my major postmodern-using projects. Note that most extra aspects of tables can be added with extra statements *after* the 'create table' command has been given, and thus can be completely separate from the dao-table-definition functionality.
Cheers, Marijn
On 6/8/08, Rafał Strzaliński nablaone@gmail.com wrote:
Hi,
I'm attaching a patch that allows to add table extra options ( :check :unique ..) to a DAO definition.
Sample:
(defclass account () ((id :col-type serial ) (login :col-type (varchar 255) :accessor login :initarg :login) (password :col-type (varchar 255) :accessor password :initarg :password) (created_at :col-type timestamp :accessor created-at :initform (now-timestamp))) (:unique name) (:metaclass dao-class) (:keys id) (:extra-options (:unique login)) (:table-name account.account))
-- Best regards, Rafal Strzalinski (nabla) http://nablaone.net
postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
2008/6/13 Marijn Haverbeke marijnh@gmail.com:
Hi Rafal,
Thanks for the patch. I don't have time to look at it right now but I'll get back to you in a week or so. Chances are, though, that I won't be including it as is.
That's not a problem. I'm using PM on my pet-project, so I can wait for a "blessed" solution.
Did you ever use Postmodern before version 1.10? The deftable form I had was going in this same direction, but it became a mess, so I decided to separate the 'class definition' part form the 'table definition' part. A feature similar to your patch that I have been thinking about including is to add something specifically for adding extra indices, sequences, and constraints to a table -- I'm already using something like it in all my major postmodern-using projects. Note that most extra aspects of tables can be added with extra statements *after* the 'create table' command has been given, and thus can be completely separate from the dao-table-definition functionality.
I would be fine if these extra aspects can be easy enabled/disabled. Droping constraints (FKs, checks, and so on) is a very common while database migration. BTW Have You ever thinking supporting a db migration, from one schema version to another one? Something similar to Rails.
Basiclly, I'm not a big fan on keeping all SQL-stuff into an application code. I like 'create.sql'/'drop.sql' kind of scripts. I'm thinking about PM port of http://www.cliki.net/clsql-pg-introspect. Maybe You already have something like that and could share :-)
Hey Rafał,
Sorry for taking godawfully long to get back on this. I've pushed a patch that adds a bunch of table-definition utilities (see postmodern/deftable.lisp, and the corresponding docs). I'd be interested to hear if they work for you.
Best, Marijn
On Fri, Jun 13, 2008 at 8:26 PM, Rafał Strzaliński nablaone@gmail.com wrote:
2008/6/13 Marijn Haverbeke marijnh@gmail.com:
Hi Rafal,
Thanks for the patch. I don't have time to look at it right now but I'll get back to you in a week or so. Chances are, though, that I won't be including it as is.
That's not a problem. I'm using PM on my pet-project, so I can wait for a "blessed" solution.
Did you ever use Postmodern before version 1.10? The deftable form I had was going in this same direction, but it became a mess, so I decided to separate the 'class definition' part form the 'table definition' part. A feature similar to your patch that I have been thinking about including is to add something specifically for adding extra indices, sequences, and constraints to a table -- I'm already using something like it in all my major postmodern-using projects. Note that most extra aspects of tables can be added with extra statements *after* the 'create table' command has been given, and thus can be completely separate from the dao-table-definition functionality.
I would be fine if these extra aspects can be easy enabled/disabled. Droping constraints (FKs, checks, and so on) is a very common while database migration. BTW Have You ever thinking supporting a db migration, from one schema version to another one? Something similar to Rails.
Basiclly, I'm not a big fan on keeping all SQL-stuff into an application code. I like 'create.sql'/'drop.sql' kind of scripts. I'm thinking about PM port of http://www.cliki.net/clsql-pg-introspect. Maybe You already have something like that and could share :-)
-- Best regards, Rafal Strzalinski (nabla) http://nablaone.net _______________________________________________ postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
2008/7/10 Marijn Haverbeke marijnh@gmail.com:
Hey Rafał,
Sorry for taking godawfully long to get back on this. I've pushed a patch that adds a bunch of table-definition utilities (see postmodern/deftable.lisp, and the corresponding docs). I'd be interested to hear if they work for you.
Thanks. It works fine. At least unique-index :-)
postmodern-devel@common-lisp.net