From slobodan.milnovic at gmail.com Sun Jan 2 13:02:09 2011 From: slobodan.milnovic at gmail.com (=?UTF-8?Q?Slobodan_Milnovi=C4=87?=) Date: Sun, 2 Jan 2011 14:02:09 +0100 Subject: [postmodern-devel] Point type Message-ID: Hi, What would be the best representation of the point type? So far, I have been using following for query: (:[] 'point-column 0) (:[] 'point-column 1) and this for update: 'point-column (:type (concatenate 'string (write-to-string x-coordinate) "," (write-to-string y-coordinate)) point) It works, but seems a bit of a kludge. And how about more complex data types that use points like these http://www.postgresql.org/docs/8.4/static/datatype-geometric.html ? From marijnh at gmail.com Sun Jan 2 13:17:13 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 2 Jan 2011 14:17:13 +0100 Subject: [postmodern-devel] Point type In-Reply-To: References: Message-ID: Hi Slobodan, To make this kind of thing less awkward, your best bet is to define a reader and a writer for the type. You can find the details in the reference guide [1], but in short, you'd: - Find a Lisp type you want to use for values of this type. In this case, I think (defstruct point x y) is a good candidate. - Figure out the OID of the point type -- I usually do this by adding (print type-id) somewhere in read-field-descriptions, and then querying a row that contains the type I'm interested in. Maybe there are better ways. - Use cl-postgres:set-sql-reader to associate this OID with a reader function that converts the string (or, if you want to be super-efficient, binary) representation of the type to a lisp value. - Specialize cl-postgres:to-sql-string on the point struct type, and have it output the Postgres-compatible string representation. Let me know if you run into trouble. Best, Marijn From sabra.crolleton at gmail.com Sun Jan 16 01:36:30 2011 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Sat, 15 Jan 2011 17:36:30 -0800 Subject: [postmodern-devel] Syntax help requested Message-ID: Hello everyone, I was doing some maintenance and decided to write some meta-functions in s-sql and ran into an issue with "any". In this particular situation I was trying to apply it to pg_index.indkey which is an int2vector. I wanted to get the indexed columns and their attributes from a table (Not the indexes, the indexed columns) The following sql string seems to work, but I wanted to put it into s-sql form. (defun list-indexed-column-and-attributes (table-name) "List the indexed columns and their attributes in a table" (when (table-exists-p table-name) (query "SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) FROM pg_index, pg_class, pg_attribute WHERE pg_class.oid = $1::regclass AND indrelid = pg_class.oid AND pg_attribute.attrelid = pg_class.oid AND pg_attribute.attnum = any(pg_index.indkey)" table-name))) I can't seem to figure out how to generate the s-sql equivalent of "any(pg_index.indkey)". I ended up with the following, completely avoiding "any". It seems to work, but because postgresql seems to be able to have up to 32 indexed columns per table, it looks clumsy. Any suggestions as to how I can do this better? Sabra (defun list-indexed-column-and- attributes-pm (table-name) "List the indexed columns and their attributes in a table" (query (:select 'pg_attribute.attname (:format_type 'pg_attribute.atttypid 'pg_attribute.atttypmod) :from 'pg_index 'pg_class 'pg_attribute :where (:and (:= 'pg_class.oid (:type table-name :regclass)) (:= 'indrelid 'pg_class.oid) (:= 'pg_attribute.attrelid 'pg_class.oid) (:or (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 0)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 1)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 2)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 3)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 4)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 5)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 6)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 7)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 8)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 9)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 10)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 11)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 12)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 13)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 14)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 15)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 16)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 17)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 18)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 19)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 20)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 21)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 22)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 23)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 24)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 25)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 26)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 27)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 28)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 29)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 30)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 31)) (:= 'pg_attribute.attnum (:[] 'pg_index.indkey 22))))))) -------------- next part -------------- An HTML attachment was scrubbed... URL: From marijnh at gmail.com Mon Jan 17 11:14:33 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 17 Jan 2011 12:14:33 +0100 Subject: [postmodern-devel] Syntax help requested In-Reply-To: References: Message-ID: Hi Sabra, user> (s-sql:sql (:select 'pg_attribute.attname (:format-type 'pg_attribute.atttypid 'pg_attribute.atttypmod) :from 'pg_index 'pg_class 'pg_attribute :where (:and (:= 'pg_class.oid (:type '$1 regclass)) (:= 'indrelid 'pg_class.oid) (:= 'pg_attribute.attrelid 'pg_class.oid) (:= 'pg_attribute.attnum (:any* 'pg_index.indkey))))) This gives me a query similar to what you want. Note the clunky :any* -- this is because Postgres has both a function-call-style any and an infix any, and S-SQL's syntax doesn't allow them to be distinguished. Best, Marijn From sabra.crolleton at gmail.com Mon Jan 17 17:49:23 2011 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Mon, 17 Jan 2011 09:49:23 -0800 Subject: [postmodern-devel] Syntax help requested In-Reply-To: References: Message-ID: Marijn, That worked. Your documents are so good and "any" does not appear as a sql-op in the documents, so I did not think to look for an additional any* op in the code. If I can find the time, I think I will compile a giant list of usage examples and put it up somewhere. That will force me to actually understand instead of just use postmodern. Many thanks. Sabra On Mon, Jan 17, 2011 at 3:14 AM, Marijn Haverbeke wrote: > Hi Sabra, > > user> (s-sql:sql (:select 'pg_attribute.attname (:format-type > 'pg_attribute.atttypid 'pg_attribute.atttypmod) > :from 'pg_index 'pg_class 'pg_attribute > :where (:and (:= 'pg_class.oid (:type '$1 > regclass)) > (:= 'indrelid 'pg_class.oid) > (:= 'pg_attribute.attrelid > 'pg_class.oid) > (:= 'pg_attribute.attnum > (:any* 'pg_index.indkey))))) > > This gives me a query similar to what you want. Note the clunky :any* > -- this is because Postgres has both a function-call-style any and an > infix any, and S-SQL's syntax doesn't allow them to be distinguished. > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From slobodan.milnovic at gmail.com Sun Jan 23 18:01:55 2011 From: slobodan.milnovic at gmail.com (=?UTF-8?Q?Slobodan_Milnovi=C4=87?=) Date: Sun, 23 Jan 2011 19:01:55 +0100 Subject: [postmodern-devel] Can interval be zero? Message-ID: Hi, I have an situation where I have an interval of "zero" time that I would like to put with the other data in the table. When I try with the (simple-date:encode-interval :millisecond 0) I get the object > (simple-date:encode-interval :millisecond 0) > # But, when I try to insert this object into the table with the insert-dao, I get the following error (I have left out other fields, for other non-zero values of interval the insert works fine). Database error 22007: invalid input syntax for type interval: "" Query: INSERT INTO mytable (someinterval) VALUES (interval E'') RETURNING somevalue [Condition of type CL-POSTGRES-ERROR:INVALID-DATETIME-FORMAT] I'm using latest postmodern from the git repository https://github.com/marijnh/Postmodern.git For now I'll use (simple-date:encode-interval :millisecond 1), but I'm wondering if this is an issue with postmodern or postgresql? From sabra.crolleton at gmail.com Sun Jan 23 19:17:38 2011 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Sun, 23 Jan 2011 11:17:38 -0800 Subject: [postmodern-devel] Can interval be zero? In-Reply-To: References: Message-ID: Hi, Interesting. It seems to be happy if you give it a simple string "0 0:0:0", or, as you've uncovered, 1 millisecond. But it doesn't like the encoding if you use (simple-date:encode-interval :anything 0) Sabra 2011/1/23 Slobodan Milnovi? > Hi, > > I have an situation where I have an interval of "zero" time that I > would like to put with the other data in the table. When I try with > the (simple-date:encode-interval :millisecond 0) I get the object > > > (simple-date:encode-interval :millisecond 0) > > # > > But, when I try to insert this object into the table with the > insert-dao, I get the following error (I have left out other fields, > for other non-zero values of interval the insert works fine). > > Database error 22007: invalid input syntax for type interval: "" > Query: INSERT INTO mytable (someinterval) VALUES (interval E'') > RETURNING somevalue > [Condition of type CL-POSTGRES-ERROR:INVALID-DATETIME-FORMAT] > > I'm using latest postmodern from the git repository > https://github.com/marijnh/Postmodern.git > > For now I'll use (simple-date:encode-interval :millisecond 1), but I'm > wondering if this is an issue with postmodern or postgresql? > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fbogdanovic at xnet.hr Mon Jan 24 11:09:51 2011 From: fbogdanovic at xnet.hr (Haris) Date: Mon, 24 Jan 2011 12:09:51 +0100 Subject: [postmodern-devel] id field Message-ID: <12BFA80C10FC4F7A85B0BAEC064E2837@komp> Hi. When I try to insert some data in table with (query "insert into ...") it asks me also to enter 'id' field which is a primary key. Shouldn't primary key field be automatically filed ? I made my table with pgadmin 3. Thanks From marijnh at gmail.com Mon Jan 24 11:31:24 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 24 Jan 2011 12:31:24 +0100 Subject: [postmodern-devel] id field In-Reply-To: <12BFA80C10FC4F7A85B0BAEC064E2837@komp> References: <12BFA80C10FC4F7A85B0BAEC064E2837@komp> Message-ID: Hi Haris, Fields are only automatically filled when they have a default value. Does your table have a default value set for the id column? Best, Marijn From marijnh at gmail.com Mon Jan 24 11:38:26 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 24 Jan 2011 12:38:26 +0100 Subject: [postmodern-devel] Can interval be zero? In-Reply-To: References: Message-ID: Hi Slobodan, I've pushed a patch to fix this. You now get "0 milliseconds" when serializing an interval whose components are all 0. I hope that solves the problem. Best, Marijn From fbogdanovic at xnet.hr Mon Jan 24 14:03:39 2011 From: fbogdanovic at xnet.hr (Haris) Date: Mon, 24 Jan 2011 15:03:39 +0100 Subject: [postmodern-devel] id field Message-ID: <9DE08FDFF6EF4AB1B3390E9A87075BDA@komp> Then I don't need primary key ? If I choose my primary key to be an integer then I have to keep track of numbers and automatically insert number incremented by one ? I worked long ago with Access and it automatically inserts number incremented by one as id. I guess than this is part of Access program and not the underlaying database ? From marijnh at gmail.com Mon Jan 24 14:14:56 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Mon, 24 Jan 2011 15:14:56 +0100 Subject: [postmodern-devel] id field In-Reply-To: <9DE08FDFF6EF4AB1B3390E9A87075BDA@komp> References: <9DE08FDFF6EF4AB1B3390E9A87075BDA@komp> Message-ID: > Then I don't need primary key ? (Read up on what primary keys really do.) > If I choose my primary key to be an integer > then I have to keep track of numbers and automatically > insert number incremented by one ? No, Postgres supports automatically assigned IDs as well, but you have to specify them. Look into the serial datatype, and default column values. From slobodan.milnovic at gmail.com Mon Jan 24 20:30:56 2011 From: slobodan.milnovic at gmail.com (=?UTF-8?Q?Slobodan_Milnovi=C4=87?=) Date: Mon, 24 Jan 2011 21:30:56 +0100 Subject: [postmodern-devel] Can interval be zero? In-Reply-To: References: Message-ID: On Mon, Jan 24, 2011 at 12:38, Marijn Haverbeke wrote: > Hi Slobodan, > > I've pushed a patch to fix this. You now get "0 milliseconds" when > serializing an interval whose components are all 0. I hope that solves > the problem. > > Best, > Marijn Hi Marijn, In this case, the postgresql receives '0 milliseconds' which it doesn't like and reports an syntax error, but I have made a small change, that corrects this and outputs interval '0 milliseconds' which postgresql accepts happily. I hope I have managed to follow the spirit of the postmodern code and the algorythm around the part that I have changed. Here is the diff, I hope this format is usefull for you, since this is the first time I have been using git diff. :-) diff --git a/simple-date/cl-postgres-glue.lisp b/simple-date/cl-postgres-glue.lisp index c07e67b..d1de8e7 100644 --- a/simple-date/cl-postgres-glue.lisp +++ b/simple-date/cl-postgres-glue.lisp @@ -33,7 +33,7 @@ (defmethod cl-postgres:to-sql-string ((arg interval)) (multiple-value-bind (year month day hour min sec ms) (decode-interval arg) (if (= year month day hour min sec ms 0) - "0 milliseconds" + (values "0 milliseconds" "interval") (flet ((not-zero (x) (if (zerop x) nil x))) (values (format nil "~@[~d years ~]~@[~d months ~]~@[~d days ~]~@[~d hours ~]~@[~d minutes ~]~@[~d seconds ~]~@[~d milliseconds~]" From achambers at mcna.net Tue Jan 25 01:21:34 2011 From: achambers at mcna.net (Andy Chambers) Date: Mon, 24 Jan 2011 20:21:34 -0500 Subject: [postmodern-devel] Bulk Copying Message-ID: Hi All, I'm trying to add support for bulk copying to postmodern. Does anyone have any ideas on how it should be done. Here's my suggestion... 1) Add message primitives (we seem to already have copy-done-message) (define-message copy-data-message #\d (data) (string data)) (define-message copy-fail-message #\f (reason) (string reason)) 2) Add a "bulk-copier" class with slots for db ; the connection we're using table ; the table we're copying from/to from/to ; whether we're copying from or to a table header ; whether to include a header row in output/input ;; plus slots for the CSV options delimiter null-str quote-str escape-str 3) A function open-copier creates an instance of the above class and sends the corresponding copy statement to Postgres before returning the object. 4) A function copy-row takes a row (i.e. a simple list of Lisp values), and writes them to the stream attached to the copier. 5) A function copy-done lets Postgres know we're finished and commits the change to the database. Anyone got any hints for debugging this low-level stuff? I seem to be able to open a copier (and send the copy statement to pg) but when I send the complete-command message in copy-done, my code is hanging. -- Andy Chambers From marijnh at gmail.com Tue Jan 25 08:07:20 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 25 Jan 2011 09:07:20 +0100 Subject: [postmodern-devel] Bulk Copying In-Reply-To: References: Message-ID: Hi Andy, Your approach sounds good. I've never used bulk data copying, so I can't really give very useful feedback. As for debugging, well, have the code log what it's sending and then double-check with the protocol docs?there are often subtle gotchas described in the 'message flow' document that aren't mentioned in the message-by-message reference. Best, Marijn From marijnh at gmail.com Tue Jan 25 08:08:48 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 25 Jan 2011 09:08:48 +0100 Subject: [postmodern-devel] Can interval be zero? In-Reply-To: References: Message-ID: Hi Slobodan, Ugh. That seems to always happen when I push something out without fully testing it. Thanks for the fix, applied. Best, Marijn From slobodan.milnovic at gmail.com Tue Jan 25 08:18:19 2011 From: slobodan.milnovic at gmail.com (=?UTF-8?Q?Slobodan_Milnovi=C4=87?=) Date: Tue, 25 Jan 2011 09:18:19 +0100 Subject: [postmodern-devel] Can interval be zero? In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 09:08, Marijn Haverbeke wrote: > Hi Slobodan, > > Ugh. That seems to always happen when I push something out without > fully testing it. Thanks for the fix, applied. No problem, if you weren't making changes, I probably wouldn't know where exactly is the problem. Thank you, and thanks for the great library that postmodern is! :-) From sebyte at smolny.plus.com Tue Jan 25 12:47:52 2011 From: sebyte at smolny.plus.com (Sebastian Tennant) Date: Tue, 25 Jan 2011 12:47:52 +0000 Subject: [postmodern-devel] Minor bug in the Simple Date reference manual Message-ID: Hi Marijn, There's a very minor bug in the Simple Date reference manual: http://marijnhaverbeke.nl/postmodern/simple-date.html The HTML title tag reads "Postmodern reference manual" whereas I belive it should read "Simple Date reference manual". It's noticeable if/when you create browser bookmarks for the reference manual of each component part of Postmodern. Seb -- Emacs' AlsaPlayer - Music Without Jolts Lightweight, full-featured and mindful of your idyllic happiness. http://home.gna.org/eap From fbogdanovic at xnet.hr Tue Jan 25 13:05:06 2011 From: fbogdanovic at xnet.hr (Haris) Date: Tue, 25 Jan 2011 14:05:06 +0100 Subject: [postmodern-devel] plists Message-ID: Hi. I didn't quite understand the :plists argument. I want for select to return me lists of plists. I tried this: (query "select * from table1;" :plists t) but it doesn't work ? P.S. What's with the Croatia example ? I'm from Croatia. From marijnh at gmail.com Tue Jan 25 13:06:22 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 25 Jan 2011 14:06:22 +0100 Subject: [postmodern-devel] Minor bug in the Simple Date reference manual In-Reply-To: References: Message-ID: Hi Sebastian, Thanks for catching that. I've pushed a fix. Best, Marijn From marijnh at gmail.com Tue Jan 25 13:10:23 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 25 Jan 2011 14:10:23 +0100 Subject: [postmodern-devel] plists In-Reply-To: References: Message-ID: Hey, > (query "select * from table1;" :plists t) It is not a keyword argument. Rather, there is a regular optional argument that gets a keyword value that determines the output format. (query "select * from table1;" :plists) should work. > P.S. What's with the Croatia example ? I'm from Croatia. I was living in Zagreb when I wrote part of the documentation. Great country! Best, Marijn From fbogdanovic at xnet.hr Tue Jan 25 20:34:49 2011 From: fbogdanovic at xnet.hr (Haris) Date: Tue, 25 Jan 2011 21:34:49 +0100 Subject: [postmodern-devel] plists Message-ID: <51FEC29FF87C41E2B344D3EC154592D4@komp> Hi. I tried (query "select * from table1;" :plists) but I get: Error: Undefined operator NIL in form (NIL (CL-POSTGRES:EXEC-QUERY *DATABASE* "select * from table1;" (QUOTE POSTMODERN::SYMBOL-PLIST-ROW-READER))) What does that mean ? I'm using Lispworks/Windows. I also tried (query "select * from table1;" :alists) and that works ok. > I was living in Zagreb ... I'm from Zagreb too. From lucas.r.hope at gmail.com Tue Jan 25 20:54:18 2011 From: lucas.r.hope at gmail.com (Lucas Hope) Date: Wed, 26 Jan 2011 07:54:18 +1100 Subject: [postmodern-devel] plists In-Reply-To: <51FEC29FF87C41E2B344D3EC154592D4@komp> References: <51FEC29FF87C41E2B344D3EC154592D4@komp> Message-ID: Hi, I too have noticed that :plist and :plists doesn't work in in the current release version. I don't really have a need for it, so I just didn't use it. Thanks for the great product. Your library has been my #1 used over the last year. It is just so good that we very rarely need to say anything here. :-) Peace, -Luke On Wed, Jan 26, 2011 at 7:34 AM, Haris wrote: > Hi. > > I tried (query "select * from table1;" :plists) but I get: > > Error: Undefined operator NIL in form (NIL (CL-POSTGRES:EXEC-QUERY > *DATABASE* "select * from table1;" (QUOTE > POSTMODERN::SYMBOL-PLIST-ROW-READER))) > What does that mean ? > I'm using Lispworks/Windows. > > I also tried (query "select * from table1;" :alists) > and that works ok. > > > I was living in Zagreb ... > > I'm from Zagreb too. > > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -- --------------------------------------------------- Dr Lucas Hope - (646) 2332123 after 3pm US EST Machine Learning and Software Engineering Consultant Melbourne, Australia -------------- next part -------------- An HTML attachment was scrubbed... URL: From marijnh at gmail.com Tue Jan 25 21:34:09 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Tue, 25 Jan 2011 22:34:09 +0100 Subject: [postmodern-devel] plists In-Reply-To: <51FEC29FF87C41E2B344D3EC154592D4@komp> References: <51FEC29FF87C41E2B344D3EC154592D4@komp> Message-ID: Hi Haris, > I tried ?(query "select * from table1;" :plists) but I get: > > Error: Undefined operator NIL in form (NIL (CL-POSTGRES:EXEC-QUERY > *DATABASE* "select * from table1;" (QUOTE > POSTMODERN::SYMBOL-PLIST-ROW-READER))) Interesting. On Allegro this seems to work fine. I don't have Lispworks installed at the moment. Could you do a little debugging yourself? For a start, what does the query form macroexpand to? And what if you macroexpand that again? I'm sort of confused about where the nil is coming from. > I'm from Zagreb too. Cool. Do you know Alan Pavicic, by any chance? You should start a Lisp user group?there's bound to be at least three Lisp programmers there ;) Best, Marijn From slobodan.milnovic at gmail.com Tue Jan 25 22:15:13 2011 From: slobodan.milnovic at gmail.com (=?UTF-8?Q?Slobodan_Milnovi=C4=87?=) Date: Tue, 25 Jan 2011 23:15:13 +0100 Subject: [postmodern-devel] plists In-Reply-To: References: <51FEC29FF87C41E2B344D3EC154592D4@komp> Message-ID: On Tue, Jan 25, 2011 at 22:34, Marijn Haverbeke wrote: >> I'm from Zagreb too. > > Cool. Do you know Alan Pavicic, by any chance? You should start a Lisp > user group?there's bound to be at least three Lisp programmers there > ;) There already is one user group, I have been on one meeting about an year ago. And Alan is still there. ;) From marijnh at gmail.com Wed Jan 26 09:53:02 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Wed, 26 Jan 2011 10:53:02 +0100 Subject: [postmodern-devel] plists In-Reply-To: <51FEC29FF87C41E2B344D3EC154592D4@komp> References: <51FEC29FF87C41E2B344D3EC154592D4@komp> Message-ID: Coming back to this problem... > Error: Undefined operator NIL in form (NIL (CL-POSTGRES:EXEC-QUERY > *DATABASE* "select * from table1;" (QUOTE > POSTMODERN::SYMBOL-PLIST-ROW-READER))) Last night I suddenly realized that this is a bug that was fixed a long time ago [1]. Get the current code from git, and it'll work. I should probably do a release again sometime soon. [1]: https://github.com/marijnh/Postmodern/commit/1627b8a8f8d19181112ba9d6b9eb544153318a32 From haragx at gmail.com Wed Jan 26 12:13:06 2011 From: haragx at gmail.com (Phil Marneweck) Date: Wed, 26 Jan 2011 14:13:06 +0200 Subject: [postmodern-devel] Date format of alist(s) Message-ID: <1296043986.2348.160.camel@devi> Hi Postmodern is returning dates like this (:DATE-OF-TERMINATION .255611203200) all of a sudden instead of simpledate objects or date string. What did I change to get this behavior or is it a setting in postgresql that has changed? Regards From marijnh at gmail.com Wed Jan 26 12:20:06 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Wed, 26 Jan 2011 13:20:06 +0100 Subject: [postmodern-devel] Date format of alist(s) In-Reply-To: <1296043986.2348.160.camel@devi> References: <1296043986.2348.160.camel@devi> Message-ID: Hi Phil, Simple-date, and the glue that integrates it in Postmodern, is no longer loaded by default. Load the :simple-date-postgres-glue system to get the old behaviour. I actually recommend people to use local-time rather than simple-date now (it also has cl-postgres glue code in its distribution now), but if you don't care about time zones, and don't want to update your code. simple-date still works. Best, Marijn From haragx at gmail.com Wed Jan 26 13:03:42 2011 From: haragx at gmail.com (Phil Marneweck) Date: Wed, 26 Jan 2011 15:03:42 +0200 Subject: [postmodern-devel] Date format of alist(s) In-Reply-To: References: <1296043986.2348.160.camel@devi> Message-ID: <1296047022.1922.29.camel@devi> Thank you that did the trick. On Wed, 2011-01-26 at 13:20 +0100, Marijn Haverbeke wrote: > Hi Phil, > > Simple-date, and the glue that integrates it in Postmodern, is no > longer loaded by default. Load the :simple-date-postgres-glue system > to get the old behaviour. > > I actually recommend people to use local-time rather than simple-date > now (it also has cl-postgres glue code in its distribution now), but > if you don't care about time zones, and don't want to update your > code. simple-date still works. > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From fbogdanovic at xnet.hr Wed Jan 26 13:21:36 2011 From: fbogdanovic at xnet.hr (Haris) Date: Wed, 26 Jan 2011 14:21:36 +0100 Subject: [postmodern-devel] plists Message-ID: I tried git clone https://github.com/marijnh/Postmodern/commit/1627b8a8f8d19181112ba9d6b9eb544153318a32 but it doesn't work. What exactly should I write to get this from git ? From marijnh at gmail.com Wed Jan 26 13:34:35 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Wed, 26 Jan 2011 14:34:35 +0100 Subject: [postmodern-devel] plists In-Reply-To: References: Message-ID: This should do the trick: git clone http://marijnhaverbeke.nl/git/postmodern From achambers at mcna.net Wed Jan 26 15:34:19 2011 From: achambers at mcna.net (Andy Chambers) Date: Wed, 26 Jan 2011 10:34:19 -0500 Subject: [postmodern-devel] syncing the socket Message-ID: Hi, My bulk copier is somewhat working now but the next time I try to issue a query on the same connection (using cl-postgres:exec-query), I'm getting "Unexpected message received: Z". I thought that putting a "try-to-sync" after sending my CopyDone message should prevent this but apparently it doesn't. Any ideas what's going on? -- Andy Chambers From marijnh at gmail.com Wed Jan 26 15:41:57 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Wed, 26 Jan 2011 16:41:57 +0100 Subject: [postmodern-devel] syncing the socket In-Reply-To: References: Message-ID: > My bulk copier is somewhat working now but the next time I try to issue a > query on > the same connection (using cl-postgres:exec-query), I'm getting > "Unexpected message > received: Z". ?I thought that putting a "try-to-sync" after sending my > CopyDone > message should prevent this but apparently it doesn't. I think your copy message handler should explicitly wait for the ReadyForQuery message if the protocol specifies that it arrives after a copy. wait-for-sync is too crude, it is used to recover from errors, shouldn't be used in regular operation. From fbogdanovic at xnet.hr Wed Jan 26 20:35:58 2011 From: fbogdanovic at xnet.hr (Haris) Date: Wed, 26 Jan 2011 21:35:58 +0100 Subject: [postmodern-devel] plists Message-ID: <9175E42B9BF345C5B1ADA15F66C051D1@komp> git clone http://marijnhaverbeke.nl/git/postmodern :plists works ok now. Thanks From sabra.crolleton at gmail.com Thu Jan 27 16:11:29 2011 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Thu, 27 Jan 2011 08:11:29 -0800 Subject: [postmodern-devel] Date format of alist(s) In-Reply-To: References: <1296043986.2348.160.camel@devi> Message-ID: Hi Marijn, I think my copy of simple-date is jealously defending its position in my code base. No matter what I do (short of completely erasing simple-date off the system), a postmodern query to a timestamp returns a simple-date object. Sabra On Wed, Jan 26, 2011 at 4:20 AM, Marijn Haverbeke wrote: > Hi Phil, > > Simple-date, and the glue that integrates it in Postmodern, is no > longer loaded by default. Load the :simple-date-postgres-glue system > to get the old behaviour. > > I actually recommend people to use local-time rather than simple-date > now (it also has cl-postgres glue code in its distribution now), but > if you don't care about time zones, and don't want to update your > code. simple-date still works. > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From marijnh at gmail.com Thu Jan 27 16:26:56 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Thu, 27 Jan 2011 17:26:56 +0100 Subject: [postmodern-devel] Date format of alist(s) In-Reply-To: References: <1296043986.2348.160.camel@devi> Message-ID: Could it be that you're using an old Postmodern version? Or that you're loading the test systems (those depend on :simple-date-postgres-glue, which will cause this wiring-in to happen). Best, Marijn From sabra.crolleton at gmail.com Fri Jan 28 04:29:05 2011 From: sabra.crolleton at gmail.com (Sabra Crolleton) Date: Thu, 27 Jan 2011 20:29:05 -0800 Subject: [postmodern-devel] Date format of alist(s) In-Reply-To: References: <1296043986.2348.160.camel@devi> Message-ID: Sigh. Loading test systems. Bangs head on wall. Thank you, Sabra On Thu, Jan 27, 2011 at 8:26 AM, Marijn Haverbeke wrote: > Could it be that you're using an old Postmodern version? Or that > you're loading the test systems (those depend on > :simple-date-postgres-glue, which will cause this wiring-in to > happen). > > Best, > Marijn > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fbogdanovic at xnet.hr Fri Jan 28 20:20:23 2011 From: fbogdanovic at xnet.hr (Haris) Date: Fri, 28 Jan 2011 21:20:23 +0100 Subject: [postmodern-devel] query Message-ID: Hi. I made a query like this: (sql (:select '* :from 'kupci :where (:and (:like 'ime (concat-string "%" (parameter "ime") "%")) (:like 'prezime (concat-string "%" (parameter "prezime") "%")))) I want not to apply "like" if the field in database entry is empty (null). Is there some predefined way to do this or I have to program it myself ? (parameter is a hunchentoot parameter after submitting a form) Thanks From marijnh at gmail.com Fri Jan 28 21:25:29 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Fri, 28 Jan 2011 22:25:29 +0100 Subject: [postmodern-devel] query In-Reply-To: References: Message-ID: You could make that part of the query dynamic, like this: (sql (:select '* :from 'kupci :where (:and (:raw (if TEST (sql (:like 'ime (concat-string "%" (parameter "ime") "%"))) t)) (:raw (if TEST2 (sql (:like 'prezime (concat-string "%" (parameter "prezime") "%"))) t))))) From fbogdanovic at xnet.hr Sat Jan 29 12:15:30 2011 From: fbogdanovic at xnet.hr (Haris) Date: Sat, 29 Jan 2011 13:15:30 +0100 Subject: [postmodern-devel] query Message-ID: <33E587DEEEBF4648916039AFB53431C4@komp> I made query like this: (sql (:select '* :from 'kupci :where (:and (:raw (if 'ime (sql (:like 'ime (concat-string "%" (parameter "ime") "%"))) t)) (:raw (if 'prezime (sql (:like 'prezime (concat-string "%" (parameter "prezime") %"))) t))))) but it doesn't work. For example, if (:like ...) for 'ime field passes and 'prezime field is null, record will not be selected. Is the test (if 'prezime ...) ok to test that the field is not null ? Or do I have to do something like (if (/= 'prezime nil) ...) ? From drewc at tech.coop Sat Jan 29 20:49:57 2011 From: drewc at tech.coop (Drew Crampsie) Date: Sat, 29 Jan 2011 12:49:57 -0800 Subject: [postmodern-devel] query In-Reply-To: <33E587DEEEBF4648916039AFB53431C4@komp> References: <33E587DEEEBF4648916039AFB53431C4@komp> Message-ID: On 29 January 2011 04:15, Haris wrote: > I made query like this: > > (sql (:select '* :from 'kupci :where (:and > (:raw (if 'ime (sql (:like 'ime (concat-string "%" (parameter "ime") "%"))) > t)) What exactly do you think (if 'symbol ....) is doing? Why? > (:raw (if 'prezime (sql (:like 'prezime (concat-string "%" (parameter > "prezime") %"))) t))))) (if 'prezim ....) , unless i'm seriously misunderstanding :raw, is also useless and will always return the true. > > but it doesn't work. I think you're mixing up the differences between Common Lisp and S-SQL. They are not the same language and have drastically different methods of evaluation. Do you know how lisp macros work? (macroexpand '(s-sql:sql (:raw (if 'foo 'bar 'bar)))) => (IF 'FOO 'BAR 'BAR) > For example, if (:like ...) for 'ime field passes and 'prezime field is > null, > record will not be selected. > Is the test (if 'prezime ...) ok to test that the field is not null ? No, that's cl:if, and knows nothing about the database. There is no IF expression in SQL. SQL has a test for not null... in s-sql i think it's pronounced (:not (:is-null 'ime)) : (macroexpand '(s-sql:sql (:not (:is-null 'ime)))) => "(not (ime IS NULL))" > Or do I have to do something like (if (/= 'prezime nil) ...) ? I'm not at all sure why you think this work work either.... do you understand the difference between the SQL macro and CL code? :RAW simply evaluates CL code to a string and inserts that. Also, if that's hunchentoot:parameter i see up there, you're in a lot more trouble then i thought. Google 'sql injection' to find out why. Basically, i think it's a good idea to learn common lisp before attempting to use embedded macro languages. On Lisp is available free and has an in-depth treatment of macros... practical common lisp is also an excellent option. Until you're comfortable with macros, you might just want to use (SANTIZED!) strings to store your queries... it seems that the SQL macro has left you very confused. Alternately, rather then writing code in a language you don't understand, spend some time learning Common Lisp before jumping into application development. Finally, if you're going to develop web applications, or _any_ application that has users, always validate and sanitize your input before using it. please. Cheers, drewc > > > _______________________________________________ > postmodern-devel mailing list > postmodern-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel > From fbogdanovic at xnet.hr Sun Jan 30 11:01:36 2011 From: fbogdanovic at xnet.hr (Haris) Date: Sun, 30 Jan 2011 12:01:36 +0100 Subject: [postmodern-devel] query Message-ID: <1AB7888BD03644EEAFFE773190AC0C8D@komp> I know what are you talking about, I read the Practical Common Lisp, I'm reading On lisp now but I didn't read all the Postmodern docs. (I know now what :raw does) What I really want is when the field is null to return true. (:is-null 'field) and what now ? Is there an expression "true" in sql ? I should subscribe myself to a sql newsgroup. From fbogdanovic at xnet.hr Sun Jan 30 12:49:10 2011 From: fbogdanovic at xnet.hr (Haris) Date: Sun, 30 Jan 2011 13:49:10 +0100 Subject: [postmodern-devel] query Message-ID: <598B1502259F457C89A756A7635C7F90@komp> I got it. I have to :or it with :is-null, like this: (sql (:select '* :from 'table :where (:or (:like 'field "%something%") (:is-null 'field)))) From marijnh at gmail.com Sun Jan 30 18:05:23 2011 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sun, 30 Jan 2011 19:05:23 +0100 Subject: [postmodern-devel] query In-Reply-To: <598B1502259F457C89A756A7635C7F90@komp> References: <598B1502259F457C89A756A7635C7F90@komp> Message-ID: Good to see you figured it out! (As an aside, please try to actually reply to your thread, rather than starting a new one for each mail. I'm not sure what you did wrong, but both gmail and the mailing list archive show this conversation as four different threads.) From fbogdanovic at xnet.hr Sun Jan 30 18:49:57 2011 From: fbogdanovic at xnet.hr (Haris) Date: Sun, 30 Jan 2011 19:49:57 +0100 Subject: [postmodern-devel] query Message-ID: I'm sorry for multiple threads. This subject was total misunderstanding by me. The thing that was confusing me was that if I don't enter a search term into the search field then it would not return that record even if some of the fields match. The right way is a dynamic query like this: (sql (:select '* :from 'kupci :where (:and (:raw (if (parameter "ime") (sql (:like 'ime (concat-string "%" (parameter "ime") "%")))))) (:raw (if (parameter "prezime") (sql (:like 'prezime (concat-string "%" (parameter "prezime") "%")))))))) I first have to check is the search term even entered into the search field. It finally works.