Fixed #470 -- Added support for database defaults on fields.#16092
Fixed #470 -- Added support for database defaults on fields.#16092felixxm merged 1 commit intodjango:mainfrom
Conversation
dd8ae3e to
bc7a375
Compare
adamchainz
left a comment
There was a problem hiding this comment.
In good shape! Some comments from pair review at the Djangocon Europe 2022 sprints...
441ea31 to
54c2bb9
Compare
2f37f0b to
74711c9
Compare
|
This SQL is generated by Django for Oracle, but leads to the INSERT INTO "FIELD_DEFAULTS_DBARTICLE" ("HEADLINE", "PUB_DATE")
SELECT * FROM (SELECT DEFAULT col_0, TO_TIMESTAMP(DEFAULT) col_1 FROM DUAL
UNION ALL SELECT DEFAULT, TO_TIMESTAMP(DEFAULT) FROM DUAL)The relevant python code: class DBArticle(models.Model):
headline = models.CharField(max_length=100, db_default="Default headline")
pub_date = models.DateTimeField(db_default=Now())
def __str__(self):
return self.headline articles = [DBArticle(), DBArticle()]
DBArticle.objects.bulk_create(articles)What I'm not yet clear on is: |
|
I can work around the above error somewhat by setting
|
|
I currently suspect that we can't use the I'm wondering if the best fix here is to change how we handle Oracle bulk inserts to use the INSERT ALL
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
SELECT * FROM dual;which I hope parallels single inserts sufficiently to support |
|
This looks like a nice feature, but someone reading the documentation (me included) might be wondering what is the recommended argument to use ( |
74711c9 to
b1c3e84
Compare
b3d538e to
888bc4f
Compare
927e510 to
026fb7d
Compare
|
@felixxm I've fixed the Oracle failures, but unfortunately this has left For some reason, occasionally the |
This comment was marked as outdated.
This comment was marked as outdated.
22d5d84 to
5b3e47d
Compare
felixxm
left a comment
There was a problem hiding this comment.
@LilyFoote Thanks 👍 I left initial comments.
4354606 to
f713b11
Compare
26c57e1 to
9643d8e
Compare
|
Pushed set of small changes, 64% reviewed 😅 Tomorrow I want to start working on tests and docs. |
|
In the light of ticket-34553 and whole saga of |
Added tests. It's funny because they work in almost all cases 😄 The only exception is the single quotation mark |
212ae5c to
9cb8c3d
Compare
|
buildbot, test on oracle. |
22e1089 to
9c9706b
Compare
|
I noticed that inserting primary keys with |
1dc0ef4 to
1c99e09
Compare
|
I pushed final edits 🚀 @LilyFoote Thanks for your humongous efforts 🥇 🌟 |
|
“Festina lente”, or “more haste, less speed” 🐢 🏅 Thank you @LilyFoote and @felixxm ! 🤘 |
Special thanks to Hannes Ljungberg for finding multiple implementation gaps. Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for reviews.
https://code.djangoproject.com/ticket/470
Rebased from #13709.