Skip to content
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

Effective slots #159

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

daninus14
Copy link
Contributor

This is a correct implementation of effective slot definitions to mito.

Please see the issue #158

By the way, are there any other slots besides those which need to be available at runtime?

I noticed table-column-references is a reader and not an accessor. Should it be set? See that I am not copying it below.

Take a look at the functionality now:

CL-USER> (defclass c1 ()
  ((name
    :col-type (or :null :text)
    :accessor name))
  (:metaclass mito:dao-table-class))
#<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
CL-USER> (closer-mop:ensure-finalized (find-class 'c1))
#<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
CL-USER> (inspect *)

The object is a STANDARD-OBJECT of type MITO.DAO.TABLE:DAO-TABLE-CLASS.
0. %TYPE: (CLASS #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>)
1. SOURCE: #S(SB-C:DEFINITION-SOURCE-LOCATION :NAMESTRING NIL :INDICES 32787)
2. PLIST: NIL
3. NAME: C1
4. CLASS-EQ-SPECIALIZER: #<SB-PCL::CLASS-EQ-SPECIALIZER #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>>
5. DIRECT-SUPERCLASSES: (#<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:SERIAL-PK-MIXIN>
                         #<STANDARD-CLASS MITO.DAO.MIXIN:DAO-CLASS>
                         #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:RECORD-TIMESTAMPS-MIXIN>)
6. DIRECT-SUBCLASSES: NIL
7. DIRECT-METHODS: (#(#<SB-MOP:STANDARD-READER-METHOD COMMON-LISP-USER::NAME, slot:NAME, (C1) {1003B70073}>
                      #<SB-MOP:STANDARD-WRITER-METHOD (COMMON-LISP:SETF COMMON-LISP-USER::NAME), slot:NAME, (T
                                                                                                             C1) {1003B70383}>
                      0 0))
8. %DOCUMENTATION: NIL
9. SAFE-P: NIL
10. FINALIZED-P: T
11. %CLASS-PRECEDENCE-LIST: (#<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
                             #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:SERIAL-PK-MIXIN>
                             #<STANDARD-CLASS MITO.DAO.MIXIN:DAO-CLASS>
                             #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:RECORD-TIMESTAMPS-MIXIN>
                             #<STANDARD-CLASS COMMON-LISP:STANDARD-OBJECT>
                             #<SB-PCL::SLOT-CLASS SB-PCL::SLOT-OBJECT>
                             #<SB-PCL:SYSTEM-CLASS COMMON-LISP:T>)
12. CPL-AVAILABLE-P: T
13. CAN-PRECEDE-LIST: (#<SB-PCL:SYSTEM-CLASS COMMON-LISP:T>
                       #<SB-PCL::SLOT-CLASS SB-PCL::SLOT-OBJECT>
                       #<STANDARD-CLASS COMMON-LISP:STANDARD-OBJECT>
                       #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:RECORD-TIMESTAMPS-MIXIN>
                       #<STANDARD-CLASS MITO.DAO.MIXIN:DAO-CLASS>
                       #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:SERIAL-PK-MIXIN>)
14. INCOMPATIBLE-SUPERCLASS-LIST: NIL
15. WRAPPER: #<SB-KERNEL:LAYOUT for C1 {50A48783}>
16. PROTOTYPE: NIL
17. DIRECT-SLOTS: (#<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS COMMON-LISP-USER::NAME>)
18. SLOTS: (#<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::CREATED-AT>
            #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::UPDATED-AT>
            #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::SYNCED>
            #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::ID>
            #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS COMMON-LISP-USER::NAME>)
19. PRIMARY-KEY: NIL
20. UNIQUE-KEYS: NIL
21. KEYS: NIL
22. TABLE-NAME: NIL
23. PARENT-COLUMN-MAP: #<HASH-TABLE :TEST EQ :COUNT 0 {1003B5E913}>
24. AUTO-PK: (:SERIAL)
25. RECORD-TIMESTAMPS: (T)
> 18 

The object is a proper list of length 5.
0. 0: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::CREATED-AT>
1. 1: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::UPDATED-AT>
2. 2: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::SYNCED>
3. 3: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::ID>
4. 4: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS COMMON-LISP-USER::NAME>
> 
0

The object is a STANDARD-OBJECT of type MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS.
0. SOURCE: NIL
1. NAME: MITO.DAO.MIXIN::CREATED-AT
2. INITFORM: NIL
3. INITFUNCTION: NIL
4. INITARGS: (:CREATED-AT)
5. %TYPE: T
6. %DOCUMENTATION: NIL
7. %CLASS: #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
8. ACCESSOR-FLAGS: 15
9. INFO: #S(SB-PCL::SLOT-INFO
            :TYPECHECK NIL
            :ALLOCATION :INSTANCE
            :LOCATION 0
            :READER #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B5747B}>
            :WRITER #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B574EB}>
            :BOUNDP #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B5755B}>
            :MAKUNBOUND #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                     :IN
                                     SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B575CB}>)
10. ALLOCATION: :INSTANCE
11. ALLOCATION-CLASS: #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN MITO.DAO.MIXIN:RECORD-TIMESTAMPS-MIXIN>
12. LOCATION: 0
13. COL-TYPE: (OR :TIMESTAMPTZ :NULL)
14. REFERENCES: NIL
15. PRIMARY-KEY: NIL
16. GHOST: NIL
> 
u

The object is a proper list of length 5.
0. 0: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::CREATED-AT>
1. 1: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::UPDATED-AT>
2. 2: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::SYNCED>
3. 3: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::ID>
4. 4: #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS COMMON-LISP-USER::NAME>
> 
4 

The object is a STANDARD-OBJECT of type MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS.
0. SOURCE: NIL
1. NAME: NAME
2. INITFORM: NIL
3. INITFUNCTION: NIL
4. INITARGS: (:NAME)
5. %TYPE: T
6. %DOCUMENTATION: NIL
7. %CLASS: #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
8. ACCESSOR-FLAGS: 15
9. INFO: #S(SB-PCL::SLOT-INFO
            :TYPECHECK NIL
            :ALLOCATION :INSTANCE
            :LOCATION 4
            :READER #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B57B7B}>
            :WRITER #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B57BEB}>
            :BOUNDP #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                 :IN
                                 SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B57C5B}>
            :MAKUNBOUND #<FUNCTION (LAMBDA (&REST SB-PCL::ARGS)
                                     :IN
                                     SB-PCL::INITIALIZE-INTERNAL-SLOT-FUNCTIONS) {1003B57CCB}>)
10. ALLOCATION: :INSTANCE
11. ALLOCATION-CLASS: #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::C1>
12. LOCATION: 4
13. COL-TYPE: (OR :NULL :TEXT)
14. REFERENCES: NIL
15. PRIMARY-KEY: NIL
16. GHOST: NIL
> 
q
; No values
CL-USER> 

In particular, notice that now we can properly use the class-slots function and get the runtime information we want without the workaround mentioned in the issue.

CL-USER> (closer-mop:class-slots (find-class 'c1))
(#<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::CREATED-AT>
 #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::UPDATED-AT>
 #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::SYNCED>
 #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS MITO.DAO.MIXIN::ID>
 #<MITO.CLASS.COLUMN:COLUMN-STANDARD-EFFECTIVE-SLOT-DEFINITIONS COMMON-LISP-USER::NAME>)

@daninus14 daninus14 marked this pull request as draft October 31, 2024 22:23
@daninus14
Copy link
Contributor Author

Work is in progress for the mito.dao.* package classes

…ach taken to dao-table-view and dao-table-mixin.

The actual definitions are in dao-table-column, named dao-table-column-standard-effective-slot-definitions
…definition to the effective slot class definition

- changed the reader to be an accessor to facilitate the change
@daninus14
Copy link
Contributor Author

Hi, please take a look at table-column-references.

I changed it in src/core/class/column.lisp to be an accessor instead of a reader so that I could copy the value from the direct class slot definition to the effective class slot definition in src/core/class/table.lisp. It's in the last commit hash 1e8e52b34d097a70cb5c1a941a71635d5d0da150.

Besides that there were no changes to how things worked. I've basically copied over to the effective slot the contents of the following slots:

  • inflate
  • deflate
  • references
  • ghost-slot-p
  • col-type
  • primary-key-p

I think that's everything that was defined in the direct slot definitions.

Is there anything else that needs to be checked?

So with this everything should be working now.

We should now be able to replace mito.class.table:table-column-slots with c2mop:class-slots and we can remove the helper functions for mito.class.table:table-column-slots as well.

@daninus14 daninus14 marked this pull request as ready for review November 2, 2024 21:23
@daninus14
Copy link
Contributor Author

Fixed a test which was missing a :col-type slot option and was failing

@daninus14
Copy link
Contributor Author

daninus14 commented Nov 2, 2024

So basically this is ready to be merged if it makes sense to you

src/core/class/table.lisp Outdated Show resolved Hide resolved
@daninus14
Copy link
Contributor Author

I had to add some extra checks for certain types of slots which do not have a col-type though they are still valid and they were producing errors. Now the col-type should properly show up in the effective slots produced by closer-mop:class-slots when they should be there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants