From sabra.crolleton at gmail.com Thu Oct 1 04:21:52 2009 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Wed, 30 Sep 2009 21:21:52 -0700 Subject: [postmodern-devel] Anyone tried to use the new recursive with in Postgresql 8.4 with S-SQL? Message-ID: I can't seem to get the syntax right using s-sql. I can write a straight sql statement, but it looks ugly in the middle of a lisp program. Sample sql statement from the postgresql docs is: WITH RECURSIVE search_graph(id, link, data, depth, path, cycle) AS ( SELECT g.id, g.link, g.data, 1, ARRAY[g.id], false FROM graph g UNION ALL SELECT g.id, g.link, g.data, sg.depth + 1, path || g.id, g.id = ANY(path) FROM graph g, search_graph sg WHERE g.id = sg.link AND NOT cycle ) SELECT * FROM search_graph; http://www.postgresql.org/docs/8.4/static/queries-with.html Sabra -------------- next part -------------- An HTML attachment was scrubbed... URL: From marijnh at gmail.com Mon Oct 5 17:40:40 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 5 Oct 2009 19:40:40 +0200 Subject: [postmodern-devel] Anyone tried to use the new recursive with in Postgresql 8.4 with S-SQL? In-Reply-To: References: Message-ID: Hi Sabra, WITH isn't a regular operator -- it has custom syntax, and as such would require a custom s-sql operator. See s-sql/s-sql.lisp, it shouldn't be too hard, looking at the :function operator, to build a def-sql-op form for :with. If you get something working, I'd be happy to add it to the distribution. Best, Marijn On Thu, Oct 1, 2009 at 6:21 AM, Sabra Crolleton wrote: > I can't seem to get the syntax right using s-sql. I can write a straight sql > statement, but it looks ugly in the middle of a lisp program. > > Sample sql statement from the postgresql docs is: > > WITH RECURSIVE search_graph(id, link, data, depth, path, cycle) AS ( > SELECT g.id, g.link, g.data, 1, > ARRAY[g.id], > false > FROM graph g > > UNION ALL > SELECT g.id, g.link, g.data, sg.depth + 1, > path || g.id, > g.id = ANY(path) > FROM graph g, search_graph sg > > WHERE g.id = sg.link AND NOT cycle > ) > SELECT * FROM search_graph; > > http://www.postgresql.org/docs/8.4/static/queries-with.html > > Sabra > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > > From attila.lendvai at gmail.com Tue Oct 6 08:24:32 2009 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Tue, 6 Oct 2009 10:24:32 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: <878wfueimn.fsf@gmail.com> References: <878wfueimn.fsf@gmail.com> Message-ID: > ?3: (SB-UNIX::NOTE-DANGEROUS-SELECT) > ?4: (SB-IMPL::SUB-SUB-SERVE-EVENT NIL NIL) > ?5: (SB-IMPL::SUB-SERVE-EVENT NIL NIL NIL) > ?6: (SB-SYS:WAIT-UNTIL-FD-USABLE 13 :INPUT NIL) > ?7: (SB-IMPL::REFILL-INPUT-BUFFER #) > ?8: (SB-IMPL::INPUT-UNSIGNED-8BIT-BYTE # T NIL) > ?9: (CL-POSTGRES::READ-UINT1 #) fyi, we have a postmodern branch which has a patch to make it use iolib as the socket backend. we also had some issues with sb-bsd-sockets before... i CC the postmodern list to give another data point why it's a good idea to have iolib as the socket backend. http://dwim.hu/darcsweb/darcsweb.cgi?r=HEAD%20postmodern;a=summary or darcs pull http://dwim.hu/darcs/postmodern/ hth, -- attila From marijnh at gmail.com Tue Oct 6 09:30:42 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 6 Oct 2009 11:30:42 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: References: <878wfueimn.fsf@gmail.com> Message-ID: Hi Attila, The changes required to use iolib instead of usocket are very tiny. That's great. If only there was some widely-supported, nice way of parameterised module loading. I don't want to simply incorporate your patch as it is -- that'd break windows support. One approach would be a feature :postmodern-use-iolib that people can push onto *features* before loading Postmodern, and conditionally replaces references to usocket with iolib. Would that work for you? As for replacing force-output with finish-output, why did you do that? It seems like it might slow some things down, and unless I am missing something, finish-output does the job. Best, Marijn From sionescu at cddr.org Tue Oct 6 09:47:54 2009 From: sionescu at cddr.org (Stelian Ionescu) Date: Tue, 06 Oct 2009 11:47:54 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: References: <878wfueimn.fsf@gmail.com> Message-ID: <1254822474.2911.5.camel@blackhole.cddr.org> On Tue, 2009-10-06 at 11:30 +0200, Marijn Haverbeke wrote: > Hi Attila, > > The changes required to use iolib instead of usocket are very tiny. > That's great. If only there was some widely-supported, nice way of > parameterised module loading. I don't want to simply incorporate your > patch as it is -- that'd break windows support. One approach would be > a feature :postmodern-use-iolib that people can push onto *features* > before loading Postmodern, and conditionally replaces references to > usocket with iolib. Would that work for you? what about depending on usocket on windows and iolib on *nix ? > As for replacing force-output with finish-output, why did you do that? > It seems like it might slow some things down, and unless I am missing > something, finish-output does the job. CLHS says: finish-output attempts to ensure that any buffered output sent to output-stream has reached its destination, and then returns. force-output initiates the emptying of any internal buffers but does not wait for completion or acknowledgment to return. On SBCL(and probably most other implementations) they are equivalent. For iolib I took the CLHS to the letter and only finish-output blocks until all buffered data is written, while force-output only sets a flag that the stream must be flushed by the next blocking operation -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From marijnh at gmail.com Tue Oct 6 10:14:50 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 6 Oct 2009 12:14:50 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: <1254822474.2911.5.camel@blackhole.cddr.org> References: <878wfueimn.fsf@gmail.com> <1254822474.2911.5.camel@blackhole.cddr.org> Message-ID: Hi Stelian, > finish-output attempts to ensure that any buffered output sent to > output-stream has reached its destination, and then returns. > > force-output initiates the emptying of any internal buffers but does not > wait for completion or acknowledgment to return. I know. The situation that we want to avoid is CL-postgres calling read on a socket that has unflushed data -- then both the server and the client will wait forever. Thus, it is enough to call force-output, which ensures that the flushing is initiated, and the next read won't block forever. Best, Marijn From attila.lendvai at gmail.com Tue Oct 6 10:35:16 2009 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Tue, 6 Oct 2009 12:35:16 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: References: <878wfueimn.fsf@gmail.com> Message-ID: > Hi Attila, hello Marijn, > The changes required to use iolib instead of usocket are very tiny. > That's great. If only there was some widely-supported, nice way of > parameterised module loading. I don't want to simply incorporate your > patch as it is -- that'd break windows support. One approach would be > a feature :postmodern-use-iolib that people can push onto *features* > before loading Postmodern, and conditionally replaces references to > usocket with iolib. Would that work for you? i think i would prefer a cl-postgres+iolib.asd. but then that leads to the question how to handle the situation of using babel for string encoding... that quickly leads to an exponential blow up. maybe iolib.asd itself pushing :iolib into *features* and conditionalizing the :depends-on on #+iolib? i really don't have a clean idea on how to do it, that's why i was quiet about the merge of this patch into cl-postgres proper. meanwhile i hope that darcs pull will keep my life simple because the divergence is small... this situation again makes me think that asdf is plain wrong and a goddamn defun based interface would be much more flexible. then it'd be a matter of another &key arg... -- attila From sionescu at cddr.org Tue Oct 6 10:42:35 2009 From: sionescu at cddr.org (Stelian Ionescu) Date: Tue, 06 Oct 2009 12:42:35 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: References: <878wfueimn.fsf@gmail.com> <1254822474.2911.5.camel@blackhole.cddr.org> Message-ID: <1254825755.2911.8.camel@blackhole.cddr.org> On Tue, 2009-10-06 at 12:14 +0200, Marijn Haverbeke wrote: > Hi Stelian, > > > finish-output attempts to ensure that any buffered output sent to > > output-stream has reached its destination, and then returns. > > > > force-output initiates the emptying of any internal buffers but does not > > wait for completion or acknowledgment to return. > > I know. The situation that we want to avoid is CL-postgres calling > read on a socket that has unflushed data -- then both the server and > the client will wait forever. Thus, it is enough to call force-output, > which ensures that the flushing is initiated, and the next read won't > block forever. Iolib socket streams don't flush the output buffer on reading. that would lead to major complications in order to be made safe -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From marijnh at gmail.com Tue Oct 6 18:48:05 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 6 Oct 2009 20:48:05 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: <1254825755.2911.8.camel@blackhole.cddr.org> References: <878wfueimn.fsf@gmail.com> <1254822474.2911.5.camel@blackhole.cddr.org> <1254825755.2911.8.camel@blackhole.cddr.org> Message-ID: > Iolib socket streams don't flush the output buffer on reading. that > would lead to major complications in order to be made safe Aren't they kind of going against the CL standard, then? From sionescu at cddr.org Tue Oct 6 19:17:01 2009 From: sionescu at cddr.org (Stelian Ionescu) Date: Tue, 06 Oct 2009 21:17:01 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: References: <878wfueimn.fsf@gmail.com> <1254822474.2911.5.camel@blackhole.cddr.org> <1254825755.2911.8.camel@blackhole.cddr.org> Message-ID: <1254856621.5917.0.camel@blackhole.cddr.org> On Tue, 2009-10-06 at 20:48 +0200, Marijn Haverbeke wrote: > > Iolib socket streams don't flush the output buffer on reading. that > > would lead to major complications in order to be made safe > > Aren't they kind of going against the CL standard, then? Not as fair as I know. I read the entire stream chapter when I wrote it and I remember no such requirement -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From marijnh at gmail.com Tue Oct 6 19:30:29 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 6 Oct 2009 21:30:29 +0200 Subject: [postmodern-devel] [Sbcl-devel] Possible bug in REFILL-INPUT-BUFFER In-Reply-To: <1254856621.5917.0.camel@blackhole.cddr.org> References: <878wfueimn.fsf@gmail.com> <1254822474.2911.5.camel@blackhole.cddr.org> <1254825755.2911.8.camel@blackhole.cddr.org> <1254856621.5917.0.camel@blackhole.cddr.org> Message-ID: >> > Iolib socket streams don't flush the output buffer on reading. that >> > would lead to major complications in order to be made safe >> >> Aren't they kind of going against the CL standard, then? > > Not as fair as I know. I read the entire stream chapter when I wrote it > and I remember no such requirement The only thing I can find in the hyperspec is: > force-output initiates the emptying of any internal buffers but does not wait for completion or acknowledgment to return. So I think your force-output should do at least *something* that, in the finite future, causes the buffers to be flushed. In case of emergency, you can just make force-output and finish-output equivalent. (As in, I'm not too anxious to modify my code unless there's a good reason to do so. Going by the Hyperspec, I think using force-output like that should be correct.) From russ at acceleration.net Wed Oct 7 21:11:05 2009 From: russ at acceleration.net (Russ Tyndall) Date: Wed, 07 Oct 2009 17:11:05 -0400 Subject: [postmodern-devel] Multiple values from row-readers Message-ID: <4ACD03E9.5070907@acceleration.net> I was wondering if it was a bug or intended behavior that row reader functions do not properly return multiple values? I am working on a cl-postgres backend to clsql, so I am not very familiar with much of the workings of this project, but noticed this somewhat odd (from my perspective) behavior. I have worked around this in the obvious way (list instead of multiple values). It seems to be a problem with the returning-effected-rows macro (which expands to a let, effectively discarding any multiple values returned from the row reader). Is there a reason not to change the definition to the following? http://paste.lisp.org/display/88358 Cheers, Russ Tyndall From marijnh at gmail.com Wed Oct 7 21:27:03 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Wed, 7 Oct 2009 23:27:03 +0200 Subject: [postmodern-devel] Multiple values from row-readers In-Reply-To: <4ACD03E9.5070907@acceleration.net> References: <4ACD03E9.5070907@acceleration.net> Message-ID: Hi Russ, >?Is there a reason not to change the definition to the following? Well, it conses more, and it messes with the invariant of the # of effected rows always being the second value returned. I think explicitly returning a list or struct when you need multiple values is a better solution than altering this macro. Best, Marijn From mikhail.shevchuk at gmail.com Sat Oct 17 13:28:37 2009 From: mikhail.shevchuk at gmail.com (Mikhail Shevchuk) Date: Sat, 17 Oct 2009 20:28:37 +0700 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error Message-ID: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> Hello, forum! I have a dao class that uses 'date' col-type: (reg_date :col-type date :initarg :date :accessor user-reg-date :initform (get-current-simple-date))) here is a (get-current-simple-date) result: # but the following error is generated when I'm trying to instantiate the object: Value # can not be converted to an SQL literal. [Condition of type SIMPLE-ERROR] Thanks in advance! -- http://blog.shevchuk.org From marijnh at gmail.com Sat Oct 17 14:12:38 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sat, 17 Oct 2009 16:12:38 +0200 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> Message-ID: Hello Mikhail, To get this to work, you need to ensure the code in simple-date/cl-postgres-glue.lisp is loaded. This is done by either ensuring simple-date is loaded *after* cl-postgres, or explicitly loading the simple-date-postgres-glue package. Best, Marijn From mikhail.shevchuk at gmail.com Sat Oct 17 14:59:49 2009 From: mikhail.shevchuk at gmail.com (Mikhail Shevchuk) Date: Sat, 17 Oct 2009 21:59:49 +0700 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> Message-ID: <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> great, it worked when I did the 'load' with this file. but (asdf:oos 'asdf:load-op :cl-postgres-glue) failed because there is no such package in postmodern 2009/10/17 Marijn Haverbeke : > Hello Mikhail, > > To get this to work, you need to ensure the code in > simple-date/cl-postgres-glue.lisp is loaded. This is done by either > ensuring simple-date is loaded *after* cl-postgres, or explicitly > loading the simple-date-postgres-glue package. > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -- http://blog.shevchuk.org From mikhail.shevchuk at gmail.com Sat Oct 17 15:54:23 2009 From: mikhail.shevchuk at gmail.com (Mikhail Shevchuk) Date: Sat, 17 Oct 2009 22:54:23 +0700 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> Message-ID: <7da939550910170854h312caec9tf0c57896a4c8f064@mail.gmail.com> this is strange, but even if I load simple-date later after cl-postgres: ; into # ; registering # as CL-POSTGRES ; registering # as CL-POSTGRES-TESTS ; loading system definition from ; /home/mico/.sbcl/systems/trivial-utf-8.asd into # ; registering # as TRIVIAL-UTF-8 ; registering # as ; TRIVIAL-UTF-8-TESTS ; loading system definition from /home/mico/.sbcl/systems/ieee-floats.asd ; into # ; registering # as IEEE-FLOATS ; registering # as IEEE-FLOATS-TESTS ; loading system definition from /home/mico/.sbcl/systems/usocket.asd into ; # ; registering # as USOCKET ; loading system definition from ; /home/mico/.sbcl/systems/split-sequence.asd into # ; registering # as SPLIT-SEQUENCE ; loading system definition from /home/mico/.sbcl/systems/md5.asd into ; # ; registering # as MD5 ; loading system definition from /home/mico/.sbcl/systems/simple-date.asd ; into # ; registering # as SIMPLE-DATE ; registering # as SIMPLE-DATE-TESTS I got the same error too. It works for me only if I run load cl-postgres-glue manually after all. It is 1.14 version of postgres btw. And thanks for your quick reply, Marijn 2009/10/17 Mikhail Shevchuk : > great, it worked when I did the 'load' with this file. > but (asdf:oos 'asdf:load-op :cl-postgres-glue) failed because there is > no such package in postmodern > > > 2009/10/17 Marijn Haverbeke : >> Hello Mikhail, >> >> To get this to work, you need to ensure the code in >> simple-date/cl-postgres-glue.lisp is loaded. This is done by either >> ensuring simple-date is loaded *after* cl-postgres, or explicitly >> loading the simple-date-postgres-glue package. >> >> Best, >> Marijn >> >> _______________________________________________ >> postmodern-devel mailing list >> postmodern-devel at common-lisp.net >> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel >> > > From marijnh at gmail.com Sat Oct 17 15:57:27 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sat, 17 Oct 2009 17:57:27 +0200 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> Message-ID: > but (asdf:oos 'asdf:load-op :cl-postgres-glue) failed because there is > no such package in postmodern For one, it is called simple-date-postgres-glue, and it is inside of the simple-date.asd file, so you have to load the simple-date system before asdf even finds it. Why loading simple-date after cl-postgres does not work I do not know. You can look at simple-date.asd, the code in there is simple and shouldn't be hard to debug. From mikhail.shevchuk at gmail.com Sat Oct 17 19:36:07 2009 From: mikhail.shevchuk at gmail.com (Mikhail Shevchuk) Date: Sun, 18 Oct 2009 02:36:07 +0700 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> Message-ID: <7da939550910171236pd20e8ebl8c795a39f92c8664@mail.gmail.com> I got it work good using the attached patch. I've just put straight :depends-on (file "cl-postgres-glue") instead of (eval-when) call. 2009/10/17 Marijn Haverbeke : >> but (asdf:oos 'asdf:load-op :cl-postgres-glue) failed because there is >> no such package in postmodern > > For one, it is called simple-date-postgres-glue, and it is inside of > the simple-date.asd file, so you have to load the simple-date system > before asdf even finds it. > > Why loading simple-date after cl-postgres does not work I do not know. > You can look at simple-date.asd, the code in there is simple and > shouldn't be hard to debug. > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -- http://blog.shevchuk.org -------------- next part -------------- A non-text attachment was scrubbed... Name: patch_direct-glue-depend.patch Type: text/x-patch Size: 751 bytes Desc: not available URL: From marijnh at gmail.com Sun Oct 18 07:49:53 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 18 Oct 2009 09:49:53 +0200 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: <7da939550910171236pd20e8ebl8c795a39f92c8664@mail.gmail.com> References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> <7da939550910171236pd20e8ebl8c795a39f92c8664@mail.gmail.com> Message-ID: Hey Mikhail, You should probably try with the darcs version. I just noticed something was changed in simple-date.asd since the last release, also replacing the eval-when with something else. darcs get http://common-lisp.net/project/postmodern/darcs/postmodern Best, Marijn From mikhail.shevchuk at gmail.com Sun Oct 18 11:00:13 2009 From: mikhail.shevchuk at gmail.com (Mikhail Shevchuk) Date: Sun, 18 Oct 2009 18:00:13 +0700 Subject: [postmodern-devel] simple-date:date and "can not be converted to an SQL literal." error In-Reply-To: References: <7da939550910170628n1bb8b1bascfda427b73a22f12@mail.gmail.com> <7da939550910170759v1be22249gbcac58b73b101834@mail.gmail.com> <7da939550910171236pd20e8ebl8c795a39f92c8664@mail.gmail.com> Message-ID: <7da939550910180400p536068ccie2806ac74546b29a@mail.gmail.com> Yes, that version works like a charm. Thanks a lot, Marijn! 2009/10/18 Marijn Haverbeke : > Hey Mikhail, > > You should probably try with the darcs version. I just noticed > something was changed in simple-date.asd since the last release, also > replacing the eval-when with something else. > > ?darcs get http://common-lisp.net/project/postmodern/darcs/postmodern > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -- http://blog.shevchuk.org From mitch at bermita.com Mon Oct 19 16:23:19 2009 From: mitch at bermita.com (Mitch Berkson) Date: Mon, 19 Oct 2009 12:23:19 -0400 Subject: [postmodern-devel] Error when using :col-type serial Message-ID: <4ADC9277.1080105@bermita.com> I defined a dao class which I would like to get a sequential id from the database. For the id slot I have: (id :col-type serial :accessor seat-id) When I try to do an update-dao with an instance of that class, I get: Error: The slot ID is unbound in the object # (an instance of class #). I'd appreciate any suggestions about what I'm doing wrong. Thank you. Mitch From marijnh at gmail.com Mon Oct 19 16:40:47 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 19 Oct 2009 18:40:47 +0200 Subject: [postmodern-devel] Error when using :col-type serial In-Reply-To: <4ADC9277.1080105@bermita.com> References: <4ADC9277.1080105@bermita.com> Message-ID: Are you calling update-dao on an instance that hasn't been inserted yet? Or on an instance that was created, then inserted, then updated, without re-fetching it from the DB? In the second case, your Postgres has to be version 8.2 of higher for this to work. (In the first case, that doesn't make any sense.) Marijn From mitch at bermita.com Mon Oct 19 17:39:59 2009 From: mitch at bermita.com (Mitch Berkson) Date: Mon, 19 Oct 2009 13:39:59 -0400 Subject: [postmodern-devel] Error when using :col-type serial In-Reply-To: References: <4ADC9277.1080105@bermita.com> Message-ID: <4ADCA46F.7010504@bermita.com> Marijn Haverbeke wrote: > Are you calling update-dao on an instance that hasn't been inserted > yet? Or on an instance that was created, then inserted, then updated, > without re-fetching it from the DB? In the second case, your Postgres > has to be version 8.2 of higher for this to work. (In the first case, > that doesn't make any sense.) > > Marijn > Thanks. That's it. I thought I was using save-dao, but I was really using update-dao. Mitch From zaries at global.co.za Sun Oct 25 15:45:07 2009 From: zaries at global.co.za (Phil Marneweck) Date: Sun, 25 Oct 2009 17:45:07 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save Message-ID: <1256485507.32153.9.camel@scatha> Hi I am trying to figure out how to exclude certain slots when persisting the dao instance to the db short of making a new object with the limited range of slots. Any ideas or advise? Thanx From marijnh at gmail.com Sun Oct 25 16:17:29 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 25 Oct 2009 17:17:29 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256485507.32153.9.camel@scatha> References: <1256485507.32153.9.camel@scatha> Message-ID: Hi Phil, I am not entirely sure what you mean. Do you want extra slots in the object that don't correspond to db columns? Then just don't give them any Postmodern-specific options, and they will be normal slots. Or you have two similar tables, one with a superset of columns of the other? In that case, make a class for the smaller table, and create one that inherits from that for the bigger table. Does that help? Best, Marijn On Sun, Oct 25, 2009 at 4:45 PM, Phil Marneweck wrote: > Hi > > I am trying to figure out how to exclude certain slots when persisting > the dao instance to the db short of making a new object with the limited > range of slots. > > Any ideas or advise? > > Thanx > > > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > From zaries at global.co.za Sun Oct 25 16:28:44 2009 From: zaries at global.co.za (Phil Marneweck) Date: Sun, 25 Oct 2009 18:28:44 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> Message-ID: <1256488124.32153.12.camel@scatha> I want slots that correspond to db columns but are not considered on insert and update. I want to use oid but dont want postmodern to try and update it because this gives an error. On Sun, 2009-10-25 at 17:17 +0100, Marijn Haverbeke wrote: > Hi Phil, > > I am not entirely sure what you mean. Do you want extra slots in the > object that don't correspond to db columns? Then just don't give them > any Postmodern-specific options, and they will be normal slots. Or you > have two similar tables, one with a superset of columns of the other? > In that case, make a class for the smaller table, and create one that > inherits from that for the bigger table. Does that help? > > Best, > Marijn > > On Sun, Oct 25, 2009 at 4:45 PM, Phil Marneweck wrote: > > Hi > > > > I am trying to figure out how to exclude certain slots when persisting > > the dao instance to the db short of making a new object with the limited > > range of slots. > > > > Any ideas or advise? > > > > Thanx > > > > > > > > _______________________________________________ > > postmodern-devel mailing list > > postmodern-devel at common-lisp.net > > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > > > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From marijnh at gmail.com Sun Oct 25 16:36:35 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 25 Oct 2009 17:36:35 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256488124.32153.12.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> Message-ID: Ah, that's a case I had not thought about before. I've never touched oid columns and similar magic things. So these have to be selected (and retrieved on insert), but not written to? It should be easy to add a new slot flag to do just that. Any chance you can do this yourself? (The relevant code is all in postmodern/table.lisp, but contains some weird MOP-related work-arounds.) Best, Marijn From zaries at global.co.za Sun Oct 25 16:54:00 2009 From: zaries at global.co.za (Phil Marneweck) Date: Sun, 25 Oct 2009 18:54:00 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> Message-ID: <1256489640.32153.28.camel@scatha> I could most propibly figure something out, I have been staring at table.lisp the whole afternoon. I need this for the postmodern-store I am writing for weblocks so if I did make the changes I would like to do it in such a way that the code can find its way into the main stream. There are a few options: - Cater just for oid ie mark a slot as the oid. - Mark any slot as not updatable. - ??? Which one would be best? On Sun, 2009-10-25 at 17:36 +0100, Marijn Haverbeke wrote: > Ah, that's a case I had not thought about before. I've never touched > oid columns and similar magic things. So these have to be selected > (and retrieved on insert), but not written to? It should be easy to > add a new slot flag to do just that. Any chance you can do this > yourself? (The relevant code is all in postmodern/table.lisp, but > contains some weird MOP-related work-arounds.) > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From marijnh at gmail.com Sun Oct 25 16:57:28 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 25 Oct 2009 17:57:28 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256489640.32153.28.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> Message-ID: > - Cater just for oid ie mark a slot as the oid. > - Mark any slot as not updatable. > - ??? Does Postgres provide more columns like this? If not, the first sounds least confusing. Or we could just call this 'read-only slots', which describes the functionality pretty well. From zaries at global.co.za Sun Oct 25 17:17:41 2009 From: zaries at global.co.za (Phil Marneweck) Date: Sun, 25 Oct 2009 19:17:41 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> Message-ID: <1256491061.32153.42.camel@scatha> There is the serial type as well and I don't know if there are GUID types I dont see any in the type list. And I think you can update a serial or specify a value on insert... I had a quick look at the code and I don't see that the record is reselected for insert under at any time so i gues serial is also not handles correctly. I think we migh thave to settle for :auto-generated and :read-only because we only want to fetch the value auto generated instances on insert to refresh the dao instance. ? On Sun, 2009-10-25 at 17:57 +0100, Marijn Haverbeke wrote: > > - Cater just for oid ie mark a slot as the oid. > > - Mark any slot as not updatable. > > - ??? > > Does Postgres provide more columns like this? If not, the first sounds > least confusing. > > Or we could just call this 'read-only slots', which describes the > functionality pretty well. > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From marijnh at gmail.com Sun Oct 25 17:25:16 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 25 Oct 2009 18:25:16 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256491061.32153.42.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> Message-ID: > I had a quick look at the code and I don't see that the record is > reselected for insert under at any time so i gues serial is also not > handles correctly. That's the :returning clause on line 199. > I think we migh thave to settle for :auto-generated ?and :read-only > because we only want to fetch the value auto generated instances on > insert to refresh the dao instance. See above. The idea is that after an insert, the instance properly reflects the row in the database. From zaries at global.co.za Sun Oct 25 18:09:07 2009 From: zaries at global.co.za (Phil Marneweck) Date: Sun, 25 Oct 2009 20:09:07 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> Message-ID: <1256494147.32153.74.camel@scatha> I notice the returning just after sending the mail :( Well then its :read-only... will let you know when i got something working...hope fully in an hour or so On Sun, 2009-10-25 at 18:25 +0100, Marijn Haverbeke wrote: > > I had a quick look at the code and I don't see that the record is > > reselected for insert under at any time so i gues serial is also not > > handles correctly. > > That's the :returning clause on line 199. > > > I think we migh thave to settle for :auto-generated and :read-only > > because we only want to fetch the value auto generated instances on > > insert to refresh the dao instance. > > See above. The idea is that after an insert, the instance properly > reflects the row in the database. > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From zaries at global.co.za Sun Oct 25 22:12:09 2009 From: zaries at global.co.za (Phil Marneweck) Date: Mon, 26 Oct 2009 00:12:09 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256494147.32153.74.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> Message-ID: <1256508729.32153.78.camel@scatha> Took a life time longer but it looks like i got it working without mangling the code to badly. I tested it with the postmodern-store I am writing looks like it works fine. On Sun, 2009-10-25 at 20:09 +0200, Phil Marneweck wrote: > I notice the returning just after sending the mail :( > > Well then its :read-only... will let you know when i got something > working...hope fully in an hour or so > > On Sun, 2009-10-25 at 18:25 +0100, Marijn Haverbeke wrote: > > > I had a quick look at the code and I don't see that the record is > > > reselected for insert under at any time so i gues serial is also not > > > handles correctly. > > > > That's the :returning clause on line 199. > > > > > I think we migh thave to settle for :auto-generated and :read-only > > > because we only want to fetch the value auto generated instances on > > > insert to refresh the dao instance. > > > > See above. The idea is that after an insert, the instance properly > > reflects the row in the database. > > > > _______________________________________________ > > postmodern-devel mailing list > > postmodern-devel at common-lisp.net > > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From marijnh at gmail.com Mon Oct 26 06:44:10 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 26 Oct 2009 07:44:10 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256508729.32153.78.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> Message-ID: > Took a life time longer but it looks like i got it working without > mangling the code to badly. Great! I'd be happy to review it and merge it into my repo. If you have a test case that demonstrates how you're using this, that would also help. From zaries at global.co.za Mon Oct 26 07:51:27 2009 From: zaries at global.co.za (Phil Marneweck) Date: Mon, 26 Oct 2009 09:51:27 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256488124.32153.12.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> Message-ID: <1256543487.32153.97.camel@scatha> I have test cases but I need to clean them up and I want to just have one last look (most of it as done late last night and code looks different in the morening ;)) before I mail it to you. One issue I have is that if you make a new instance of a dao and the record alread exist in the db and you run save on this the record the update is done correctly. It does not however populate the oid in an update only in an insert. I am not sure whether this is postmodern's problem or the users. For me it is in a sense the user/programmer problem. However letting postmodern protect itself against such would keep the is this a bug or feature mails on the mailing list down to a minumum. The only other time that I can think of that this could become an issue is if the user has triggers on the table that change data before it goes into the db. Then updating the object after a an update would be essential but then you cant just check for unbound slots you have to check all the fields. On Mon, 2009-10-26 at 07:44 +0100, Marijn Haverbeke wrote: > > Took a life time longer but it looks like i got it working without > > mangling the code to badly. > > Great! I'd be happy to review it and merge it into my repo. If you > have a test case that demonstrates how you're using this, that would > also help. > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From realistschuckle at gmail.com Tue Oct 27 03:23:48 2009 From: realistschuckle at gmail.com (Curtis Schlak) Date: Mon, 26 Oct 2009 22:23:48 -0500 Subject: [postmodern-devel] Patch for with-column-writers? Message-ID: <84a8885b0910262023q6b00ff90xef1391d810bc371d@mail.gmail.com> I tried multiple ways to get the with-column-writers macro in the repository to work and could not. I believe that the loop should read :in rather than :on as follows: (defmacro with-column-writers ((&rest defs) &body body) `(let ((*custom-column-writers* (append (list ,@(loop :for (field writer) :in defs :collect `(cons (to-sql-name ,field) ,writer))) *custom-column-writers*))) , at body)) With that in place, the following code works correctly: (defclass foo () ((id :col-type int :initform :id :accessor foo-id) (stuff :initform :stuff :accessor foo-stuff)) (:metaclass postmodern:dao-class) (:keys id)) (setf foo (postmodern:with-column-writers ((:id #'(lambda (inst val) (setf (foo-id inst) val) (setf (foo-stuff inst) (format nil "My Value: ~A" val))))) (postmodern:get-dao 'foo 1))) From marijnh at gmail.com Tue Oct 27 07:44:59 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 27 Oct 2009 08:44:59 +0100 Subject: [postmodern-devel] Patch for with-column-writers? In-Reply-To: <84a8885b0910262023q6b00ff90xef1391d810bc371d@mail.gmail.com> References: <84a8885b0910262023q6b00ff90xef1391d810bc371d@mail.gmail.com> Message-ID: Hi Curtis, It seems this has been broken ever since I introduced it. I actually had code that used it, but never noticed that also didn't work. How embarrassing. The intent was for the arguments to be a plain list, not a list of lists, so there was a :by #'cddr missing from the loop. I've pushed a fix. if you change your code like this, it should work: > (setf foo > ? ? ?(postmodern:with-column-writers > ? ? ? ?(:id #'(lambda (inst val) > ? ? ? ?? ? ? ? ?(setf (foo-id inst) val) > ? ? ? ?? ? ? ? ?(setf (foo-stuff inst) > ? ? ? ?? ? ? ? ? ? ? ?(format nil "My Value: ~A" val)))) > ?(postmodern:get-dao 'foo 1))) Let me know if you have any more problems. Best, Marijn From marijnh at gmail.com Tue Oct 27 09:30:35 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 27 Oct 2009 10:30:35 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256543487.32153.97.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> <1256543487.32153.97.camel@scatha> Message-ID: Phil, Sending code to the list is okay. I have incorporated your changes, with the difference that I'm now calling the option :ghost, since :read-only might actually lead people to expect something completely different. Let me know if the changes work for you. Best, Marijn From zaries at global.co.za Tue Oct 27 09:52:09 2009 From: zaries at global.co.za (Phil Marneweck) Date: Tue, 27 Oct 2009 11:52:09 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256489640.32153.28.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> <1256543487.32153.97.camel@scatha> Message-ID: <1256637129.32153.172.camel@scatha> Hi I will give it a try just now. This feauture might come in handier than expected. It can be used to build objects over "views". This way you can also persist the "main" table in the view from the dao. The "view objects" is going to be an issue for me in the weblocks store. I see that clsql has joins in there objects. How to work with views and dao combination is not clear in my mind yet. Maybe we should look at complete ghost daos? Any ideas? On Tue, 2009-10-27 at 10:30 +0100, Marijn Haverbeke wrote: > Phil, > > Sending code to the list is okay. > > I have incorporated your changes, with the difference that I'm now > calling the option :ghost, since :read-only might actually lead people > to expect something completely different. Let me know if the changes > work for you. > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From marijnh at gmail.com Tue Oct 27 09:58:11 2009 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 27 Oct 2009 10:58:11 +0100 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: <1256637129.32153.172.camel@scatha> References: <1256485507.32153.9.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> <1256543487.32153.97.camel@scatha> <1256637129.32153.172.camel@scatha> Message-ID: Can you be more specific about the problems that come up with views? In the past, I've just used regular DAO classes on views, and never updated or inserted them. From zaries at global.co.za Tue Oct 27 10:11:57 2009 From: zaries at global.co.za (Phil Marneweck) Date: Tue, 27 Oct 2009 12:11:57 +0200 Subject: [postmodern-devel] Exlcuding slots dao-save In-Reply-To: References: <1256485507.32153.9.camel@scatha> <1256491061.32153.42.camel@scatha> <1256494147.32153.74.camel@scatha> <1256508729.32153.78.camel@scatha> <1256543487.32153.97.camel@scatha> <1256637129.32153.172.camel@scatha> Message-ID: <1256638317.32153.181.camel@scatha> It is the combination of weblocks and "views" (with views i mean just a query with joins, groupings etc) that is the problem. I suspect that weblocks thinks any object has a one to one relation to a table and thus treats it like that. However I could be wrong I still need to do some more testing to see what weblocks' behaviour/expectations are exactly. Once I have done that I will come back to you with more specifics. On Tue, 2009-10-27 at 10:58 +0100, Marijn Haverbeke wrote: > Can you be more specific about the problems that come up with views? > In the past, I've just used regular DAO classes on views, and never > updated or inserted them. > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel From realistschuckle at gmail.com Wed Oct 28 03:57:07 2009 From: realistschuckle at gmail.com (Curtis Schlak) Date: Tue, 27 Oct 2009 22:57:07 -0500 Subject: [postmodern-devel] Patch for with-column-writers? Message-ID: <84a8885b0910272057o567caac5v6c63aca3e6989d6b@mail.gmail.com> Marijn, Brilliant! Thank you for the fix. I enjoy your libraries and, if I find something else that can help, I'll be sure to send the email. Skaal! Curtis.