Skip to content

orm: fix option field with default null value#24228

Merged
spytheman merged 2 commits into
vlang:masterfrom
kbkpbot:fix-orm-option-field-with-default-null-value
Apr 15, 2025
Merged

orm: fix option field with default null value#24228
spytheman merged 2 commits into
vlang:masterfrom
kbkpbot:fix-orm-option-field-with-default-null-value

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Apr 15, 2025

Copy link
Copy Markdown
Contributor

This PR fix PR #24222

For struct option fields with default values, a null in database field should update the struct's field to none, not it's default value.

@[table: 'sys_users']
struct UserPart {
	id         int @[primary; serial]
	name       string
	created_at time.Time @[sql_type: 'TIMESTAMP']
	updated_at time.Time @[sql_type: 'TIMESTAMP']
	option_i8	?i8 = 13		// option with default test
	option_string ?string = 'this is not none'
}

for example, if database field option_i8, option_string are null, then these fields should set to none, not their default values.

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22610

@spytheman spytheman merged commit 711470d into vlang:master Apr 15, 2025
@kbkpbot kbkpbot deleted the fix-orm-option-field-with-default-null-value branch April 15, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants