From piranha at thoughtcrime.us Sat May 10 07:08:54 2008 From: piranha at thoughtcrime.us (J.P. Larocque) Date: Sat, 10 May 2008 00:08:54 -0700 Subject: [postmodern-devel] Guarding against DB-NULL from other packages in :CREATE-TABLE Message-ID: <20080510070852.GA24198@synthetic-forms.ely.ath.cx> Hi, I'm defining tables with Postmodern and made the mistake of specifying a column type such as (OR TEXT DB-NULL), where DB-NULL was a symbol newly interned into my current package rather than the symbol in the S-SQL package. This resulted in SQL expressions with illegal syntax being generated (e.g. "column_name OR NOT NULL"). After tracking down the problem and finding it was my fault, I made changes (attached) to catch column-type errors earlier. The patch signals an error in DEF-SQL-OP :CREATE-TABLE when a column type is a list which begins with OR and does not meet the other original criteria for an or-db-null type: DB-NULL is a member, and length is 3. It also now ensures that DB-NULL doesn't occur twice, or on its own, outside of an OR compound type. I didn't do anything to validate other "compound" types such as NUMERIC. You might find it a bit odd that I format the DB-NULL symbol in my ERROR calls with ~S in the format control string instead of simply putting "DB-NULL" in the string: (error "Illegal compound type for column: ~S~ ~&(Only (~S x ~S) and (~S ~S x) are allowed.)" type 'or 'db-null 'or 'db-null)) This ensures that the S-SQL package name is prefixed to the symbol name--but only if S-SQL was not imported by the current package. This emphasizes to these users that DB-NULL was not imported into their current package and this is probably what their problem is. For instance: Illegal compound type for column: (OR TEXT DB-NULL) (Only (OR x S-SQL) and (OR S-SQL x) are allowed.) [Condition of type SIMPLE-ERROR] -- J.P. Larocque: , +1 509 324-2410 -------------- next part -------------- A non-text attachment was scrubbed... Name: postmodern-1.12-or-db-null.diff Type: text/x-diff Size: 1521 bytes Desc: not available URL: From marijnh at gmail.com Sat May 10 08:15:02 2008 From: marijnh at gmail.com (Marijn Haverbeke) Date: Sat, 10 May 2008 10:15:02 +0200 Subject: [postmodern-devel] Guarding against DB-NULL from other packages in :CREATE-TABLE In-Reply-To: <20080510070852.GA24198@synthetic-forms.ely.ath.cx> References: <20080510070852.GA24198@synthetic-forms.ely.ath.cx> Message-ID: Hello, Good call. I've pushed a somewhat simplified patch that should have the same effect. Cheers, Marijn