New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default initargs and accessors #38

Merged
merged 4 commits into from Sep 24, 2018

Conversation

Projects
None yet
2 participants
@fukamachi
Owner

fukamachi commented Sep 24, 2018

This is a common pattern of defining a table class:

(defclass user ()
  ((name :col-type (:varchar 64)
         :initarg :name
         :accessor user-name)
   (email :col-type (or (:varchar 128) :null)
          :initarg :email
          :accessor user-email))
  (:metaclass mito:dao-table-class))

With this patch, it can be written like this:

(mito:deftable user ()
  ((name :col-type (:varchar 64))
   (email :col-type (or (:varchar 128) :null))))

deftable adds the default :initarg and :accessor, so those are still available.

(user-name (make-instance 'user :name "fukamachi'))
;=> "fukamachi"

The default accessor prefix can be changed with :conc-name class option.

(mito:deftable user ()
  ((name :col-type (:varchar 64))
   (email :col-type (or (:varchar 128) :null)))
  (:conc-name my-))

(my-name (make-instance 'user :name "fukamachi"))
;=> "fukamachi"

If you don't need them, adding (:conc-name nil) prevents it.

(mito:deftable user ()
  ((name :col-type (:varchar 64))
   (email :col-type (or (:varchar 128) :null)))
  (:conc-name nil))
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Sep 24, 2018

Coverage Status

Coverage decreased (-0.4%) to 71.625% when pulling 01e7d84 on default-initargs-and-accessors into a4fd044 on master.

coveralls commented Sep 24, 2018

Coverage Status

Coverage decreased (-0.4%) to 71.625% when pulling 01e7d84 on default-initargs-and-accessors into a4fd044 on master.

@fukamachi fukamachi merged commit fc02c7c into master Sep 24, 2018

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment