mito icon indicating copy to clipboard operation
mito copied to clipboard

":NULL fell through ETYPECASE expression" for nullable column

Open svetlyak40wt opened this issue 5 years ago • 0 comments

Seems with commit https://github.com/fukamachi/mito/commit/be0ea57df921aa1beb2045b50a8c2e2e4f8b8955 we broke a selection of the nullable columns

How to reproduce

Create a class like this:

(defclass test-project ()
  ((processed-at :col-type (or :timestamptz :null)
                        :initarg :processed-at
                        :initform nil
                        :accessor get-processed-at
                        :documentation "Date and time a check was finished at."))
  (:metaclass dao-table-class))

Then execute:

(mito:count-dao 'test-project :processed-at :null)

It should produce a following error:

:NULL fell through ETYPECASE expression.
Wanted one of (INTEGER LOCAL-TIME:TIMESTAMP STRING NULL).
   [Condition of type SB-KERNEL:CASE-FAILURE]

Restarts:
 0: [RETRY] Retry SLY mREPL evaluation request.
 1: [*ABORT] Return to SLY's top level.
 2: [ABORT] abort thread (#<THREAD "sly-channel-1-mrepl-remote-1" RUNNING {100BE7EAD3}>)

Backtrace:
 0: ((:METHOD MITO.DAO.COLUMN:DEFLATE-FOR-COL-TYPE ((EQL :DATETIME) T)) #<unused argument> :NULL) [fast-method]
 1: (MITO.DAO::WHERE-AND (:PROCESSED-AT :NULL) #<DAO-TABLE-CLASS ULTRALISP/MODELS/CHECK::TEST-PROJECT>)
 2: (MITO.DAO:COUNT-DAO #<DAO-TABLE-CLASS ULTRALISP/MODELS/CHECK::TEST-PROJECT> :PROCESSED-AT :NULL)
 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (MITO.DAO:COUNT-DAO (QUOTE TEST-PROJECT) :PROCESSED-AT :NULL) #<NULL-LEXENV>)
 4: (EVAL (MITO.DAO:COUNT-DAO (QUOTE TEST-PROJECT) :PROCESSED-AT :NULL))
 5: ((LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1))

It worked before the be0ea57df921aa1beb2045b50a8c2e2e4f8b8955 commit.

Trying to call with nil instead of :null does not work either:

(mito:count-dao 'test-project :processed-at nil)

however error is different:

There is no primary method for the generic function
  #<STANDARD-GENERIC-FUNCTION SXQL.SQL-TYPE:YIELD (58)>
when called with arguments
  (NIL).
   [Condition of type SB-PCL::NO-PRIMARY-METHOD-ERROR]

Restarts:
 0: [RETRY] Retry calling the generic function.
 1: [RETRY] Retry SLY mREPL evaluation request.
 2: [*ABORT] Return to SLY's top level.
 3: [ABORT] abort thread (#<THREAD "sly-channel-1-mrepl-remote-1" RUNNING {100BE7EAD3}>)

Backtrace:
 0: ((:METHOD SB-PCL::NO-PRIMARY-METHOD (T)) #<STANDARD-GENERIC-FUNCTION SXQL.SQL-TYPE:YIELD (58)> NIL) [fast-method]
 1: ((LAMBDA (SB-PCL::.ARG0. SB-INT:&MORE SB-PCL::.DFUN-MORE-CONTEXT. SB-PCL::.DFUN-MORE-COUNT.) :IN "/root/.cache/common-lisp/sbcl-1.4.11-linux-x64/app/quicklisp/dists/ultralisp/software/fukamachi-mito-2..
 2: (SB-PCL::CALL-NO-PRIMARY-METHOD #<STANDARD-GENERIC-FUNCTION SXQL.SQL-TYPE:YIELD (58)> (NIL))
 3: ((FLET SB-PCL::%NO-PRIMARY-METHOD) #<STANDARD-GENERIC-FUNCTION SXQL.SQL-TYPE:YIELD (58)> (NIL))
 4: ((SB-PCL::EMF SXQL.SQL-TYPE:YIELD) #<unused argument> #<unused argument> NIL)
 5: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.SQL-TYPE:INFIX-OP)) #<error printing object>) [fast-method]
 6: ((:METHOD SXQL.SQL-TYPE:YIELD :AROUND (T)) #<error printing object>) [fast-method]
 7: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.SQL-TYPE:CONJUNCTIVE-OP)) #<error printing object>) [fast-method]
 8: ((:METHOD SXQL.SQL-TYPE:YIELD :AROUND (T)) #<error printing object>) [fast-method]
 9: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.SQL-TYPE:CONJUNCTIVE-OP)) #<error printing object>) [fast-method]
10: ((:METHOD SXQL.SQL-TYPE:YIELD :AROUND (T)) #<error printing object>) [fast-method]
11: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.SQL-TYPE:EXPRESSION-CLAUSE)) #<error printing object>) [fast-method]
12: ((:METHOD SXQL.SQL-TYPE:YIELD :AROUND (T)) #<error printing object>) [fast-method]
13: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.SQL-TYPE:SQL-COMPOSED-STATEMENT)) #<error printing object>) [fast-method]
14: ((:METHOD SXQL.SQL-TYPE:YIELD (SXQL.STATEMENT:SELECT-STATEMENT)) #<error printing object>) [fast-method]
15: ((SB-PCL::EMF SXQL.SQL-TYPE:YIELD) #<error printing object>)
16: ((:METHOD MITO.DB:RETRIEVE-BY-SQL (SXQL.SQL-TYPE:SQL-STATEMENT)) #<error printing object>) [fast-method]
17: ((SB-PCL::EMF MITO.DB:RETRIEVE-BY-SQL) #<error printing object>)
18: (MITO.DAO:COUNT-DAO #<DAO-TABLE-CLASS ULTRALISP/MODELS/CHECK::TEST-PROJECT> :PROCESSED-AT NIL)

The same problem with retrieve-dao and find-dao.

Don't know how to solve this problem.

svetlyak40wt avatar Jul 07 '19 11:07 svetlyak40wt