- (let ((result
- (mapcar #'cadr
- (database-query
- (format nil
- "SHOW COLUMNS FROM ~A LIKE '~A'" table attribute)
- database nil))))
- (let* ((str (car result))
- (end-str (position #\( str))
- (substr (subseq str 0 end-str)))
- (if substr
- (intern (string-upcase substr) :keyword) nil))))
+ (let ((row (car (database-query
+ (format nil
+ "SHOW COLUMNS FROM ~A LIKE '~A'" table attribute)
+ database nil nil))))
+ (let* ((raw-type (second row))
+ (null (third row))
+ (start-length (position #\( raw-type))
+ (type (if start-length
+ (subseq raw-type 0 start-length)
+ raw-type))
+ (length (when start-length
+ (parse-integer (subseq raw-type (1+ start-length))
+ :junk-allowed t))))
+ (when type
+ (values (ensure-keyword type) length nil (if (string-equal null "YES") 1 0))))))