Closed danskarda closed 1 year ago
I'm very happy that you are submitting improvements to this adapter. I don't currently use it, and it is in alpha status, but I'm very interested in it getting better. That said, does your add-referential-column-statement
method break the other database's support for migrations? If so, then I'm going to have to insist that you complete the work there, and make sure it tests out. I don't remember if there are tests for the migrations, though. It's been a while since I looked at this code, and it was originally heavily contributed by others.
On the relaxation of constraints. Well, mainly that is to fix problems with automatic generation of saves in a transaction. The current logic doesn't do a very good job of figuring out how to get a save to work when there are arbitrary constraints that might temporarily be unsatisfied while issuing the statements in a transaction. Would love a patch for that that is better than relaxing constraints.
You are right. I was too enthusiastic when I wrote one record to the database :) Just to hit a roadblock few miles later.
Now I see that it is necessary to relax constrains to save more complex data structures. Even more - now I understand why the model in our ms sql database avoids cyclic relations and models features like "account primary user" as a flag, not as a reference.
My proposal for going onward with ms sql:
Right, I'll add you to the repo so you can manage PRs and issues. There are some existing help-wanted open issues that are related to this.
We're probably going to need some addl declarations on the attributes in order to instruct the save system how to proceed.
IF the SQL schema has no loops (which would require some kind of constraint give-n-take) then it might be possible to just sort the statements such that the references are written last. Depends on the NULL handling of said references. If NULL is allowed, then we could do all inserts of scalars, then issue updates to set references...but if the columns are also NOT NULL then sorting the INSERT statements might be doable (if there are not cycles). If there are cycles and NOT NULL constraints, it seems you have to have a way of relaxing the constraint during a transaction or it would be impossible to proceed.
As stated in #13 MS SQL uses ANSI syntax to obtain next sequence value.
This patch:
Some notable remarks:
relax-constraints!
is empty for MSSQL Adapter as it seems MS SQL does not have this ability. It can only disable individual table constrains using ALTER TABLE :(add-referential-column-statemen
empty for the momentI run
clojure -M:dev:test:clj-tests
with success. However I am afraid that the only test for INSERT I have seen callscalar-insert
, which does not include call togenerate-tempids
. I guess that use of sequences is not covered by test.