Comments (3)
It turns out that (slot-value 'foo-1 'parent-column-map)
, (see here) doesn't have file-dao
. Is this a design on purpose?
from mito.
Seems to be a bug.
from mito.
Here is my simple work around @fukamachi
(defun add-referencing-slots (initargs)
(let ((parent-column-map NIL))
(loop for column in (getf initargs :direct-superclasses)
when (and (not (eq 'standard-class (type-of column)))
(slot-value column 'parent-column-map))
do (alexandria:unionf parent-column-map
(alexandria:hash-table-alist (slot-value column 'parent-column-map))))
(setf parent-column-map (alexandria:alist-hash-table parent-column-map :test 'eq))
(setf (getf initargs :direct-slots)
(loop for column in (getf initargs :direct-slots)
for (col-type not-null) = (multiple-value-list (parse-col-type (getf column :col-type)))
if (typep col-type '(and symbol (not null) (not keyword)))
append
(let* ((name (getf column :name))
;; FIXME: find-class raises an error if the class is this same class or not defined yet.
(rel-class (find-class col-type))
(pk-names (table-primary-key rel-class)))
(unless pk-names
(error "Foreign class ~S has no primary keys."
(class-name rel-class)))
(rplacd (cdr column)
`(:ghost t ,@(cddr column)))
(cons column
(mapcar (lambda (pk-name)
(let ((rel-column-name (rel-column-name name pk-name)))
(setf (gethash rel-column-name parent-column-map) name)
`(:name ,rel-column-name
:initargs (,(intern (symbol-name rel-column-name) :keyword))
:col-type ,(if not-null
col-type
`(or ,col-type :null))
:primary-key ,(getf column :primary-key)
:references (,col-type ,pk-name))))
pk-names)))
collect column))
(values initargs parent-column-map)))
(defmethod initialize-instance :around ((class table-class) &rest initargs)
(multiple-value-bind (initargs parent-column-map)
(add-referencing-slots initargs)
(let ((class (apply #'call-next-method class initargs)))
(setf (slot-value class 'parent-column-map)
(alexandria:alist-hash-table
(union (alexandria:hash-table-alist (slot-value class 'parent-column-map))
(alexandria:hash-table-alist parent-column-map))))
(expand-relational-keys class 'primary-key)
(expand-relational-keys class 'unique-keys)
(expand-relational-keys class 'keys)
class)))
Should work with the simplest case.
from mito.
Related Issues (20)
- transactions and rollbacks. HOT 4
- join queries with mito HOT 2
- Support for foreign key and other constrains. HOT 6
- Function disconnect-toplevel makes *connection* unbound which breaks connected-p HOT 1
- Feature: migration, not null constraint failed: provide default? HOT 2
- Question: how to select, filter (when clause) and count the results? HOT 2
- Does not load on ABCL 1.8.0 on Windows HOT 2
- (mito:find-dao can't find column like dict_name_cn HOT 4
- The value of CL-POSTGRES::PARAMETERS is 2327607654652096140, which is not of type LIST HOT 1
- underscores break slot names
- `:deflate` slot option not being called when defining a relationship
- Error when retrieving a View from the database HOT 2
- find-dao cannot find NULL values in row (includes patch)
- Unused function exists in macro expansion result of select-dao, and compiler-note is displayed.
- mito:migrate-table fails
- Calling the function mito:table-exists-p results in an error HOT 1
- Logger Error on ECL. (There exists no package with name NIL) HOT 3
- Proposal to check early for null values (on `find-dao` and friends)
- LIST column type and automatically handling many-to-many relations HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mito.