-
Notifications
You must be signed in to change notification settings - Fork 285
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
@Default decorator throws error #718
Comments
Try: @table
export class CampaignPhase extends Model<CampaignPhase> {
@Column
name!: string;
@NotNull
@Default(1)
@Column // in the last position
sort!: number;
@Foreignkey(() => CampaignTemplate)
@Column
templateId!: number;
@BelongsTo(() => CampaignTemplate)
template?: CampaignTemplate;
} |
I will try that with @default, but tried that order of operations earlier
this week with @comment and it didn't work
On Wed, Dec 18, 2019 at 11:58 AM Max Rogério ***@***.***> wrote:
Try:
@tableexport class CampaignPhase extends Model<CampaignPhase> {
@column
name!: string;
@NotNull
@default(1)
@column // in the last position
sort!: number;
@foreignkey(() => CampaignTemplate)
@column
templateId!: number;
@BelongsTo(() => CampaignTemplate)
template?: CampaignTemplate;
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#718>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6MH5OGBTMEPBGSLPNA5D3QZJQGFANCNFSM4JZVQNYQ>
.
--
Byron Ferguson
ferguson.bs@gmail.com
|
Hey @byronferguson could you solve your issue? |
I was not able to solve the issue I raised. |
@byronferguson could it be that you faced another issue after correcting the order of annotations? The following throws @NotNull
@Default(1)
@Column
sort!: number; But when using this setup instead, it works very well: @AllowNull(true)
@Default(1)
@Column
sort!: number; Hope this helps! |
I'm getting a sql syntax error using default value with dialect mssql: {
message: "Incorrect syntax near the keyword 'DEFAULT'.",
code: 'EREQUEST',
number: 156,
state: 1,
class: 15,
serverName: 'xxxx',
procName: '',
lineNumber: 1,
sql: 'ALTER TABLE [dbo].[tb_test] ALTER COLUMN [is_active] BIT NOT NULL DEFAULT 0;',
parameters: undefined
} I think for mssql you should add a constraint no the column, not just alter column: ALTER TABLE [dbo].[tb_test] ADD CONSTRAINT [DF_tb_test_is_active] DEFAULT ((0)) FOR [is_active] I'm not sure if it's needed, but if so, before dropping a table with default constraints all default constraints should be dropped first. You can query them with: SELECT * FROM sys.default_constraints WHERE parent_object_id = OBJECT_ID('[dbo].[tb_test]') |
Versions
I'm submitting a ...
[ x ] bug report
[ ] feature request
Actual behavior:
Error: @Column annotation is missing for "sort" of class "CampaignPhase" or annotation order is wrong.
Currently throwing an error. (does the same thing with
@Comment()
tooExpected behavior:
generate the DEFAULT_VALUE in the database engine
Related code:
The text was updated successfully, but these errors were encountered: