Support default expression value of another field in a table
See original GitHub issueI want to match exposed schema declaration to the following sql:
alter table entry
add column entry_id uuid not null default (id);
-- entry has a field named id
(this won’t work with raw sql but is this possible with exposed?)
But how can I do this using exposed syntax, except for defining my own custom expression? I couldn’t find ways to convert column to Expression, couldn’t do it using CustomFunction, haven’t found any other ways
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Set default values for fields or controls - Microsoft Support
This article explains how to set a default value for a table field or for a control on a form in an Access...
Read more >Get Default Values For Fields from a Table in your ... - YouTube
In this video, I'm going to show you how to create a System Defaults table that you can use to provide default values...
Read more >Set a Field's Default Value in an MS Access Table –
A default value is automatically entered in a field for a new record. You can set a default value for table fields set...
Read more >Derive a Table Column's Default Value from another ... - Vertica
When you set a default value, Vertica evaluates the DEFAULT expression and sets the column on load operations, if the operation omits a...
Read more >sql - Add a column to a table with a default value equal to the ...
..yes, but this will work for the existing rows only. It will not set the [newcolumn] value when new rows are inserted. You...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, I just settled on treating this functionality as impossible to implement using neither sql or orms of any kind. We can close this if we mention that this is not supported somewhere in the docs
There’s
clientDefault
in Exposed that could work theoretically, but I don’t think would work practically.To reference ID of a newly created row, you need to somehow obtain it first. Currently the default values are set independently from one another: https://github.com/JetBrains/Exposed/blob/9c0d2955424e3521abe025dcbdb932544aa8f3f1/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/InsertStatement.kt#L95
And I don’t see any guarantees that your EntityID default value will be initialized first.