Skip to content

orm: fix type alias not supported in table columns - #24062

Merged
spytheman merged 5 commits into
vlang:masterfrom
mid1221213:fix-type-alias-not-supported-in-orm
Apr 1, 2025
Merged

spytheman merged 5 commits into
vlang:masterfrom
mid1221213:fix-type-alias-not-supported-in-orm

Conversation

@mid1221213

Copy link
Copy Markdown
Contributor

Corollary to #15478, which fixes the type alias support for db type, this commit allows the use of an alias to a supported type in a column.

The fix is mainly replacing field.typ occurrences with table.final_type(field.typ) or equivalent.

Example use:

type CountryCode = string

@[table: 'addresses']
pub struct Address {
	id      int @[primary; sql: serial]
	name    string
	address string
	country CountryCode
}

// …

sql db {
	create table Address
} or { panic("don't panic!") }

Created as a draft because all comments welcome and and tests / doc not yet written because of this.

Corollary to vlang#15478, which fixes the type alias support
for db type, this commit allows the use of an alias to a
supported type in a column.
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22453

@spytheman

Copy link
Copy Markdown
Contributor

Please add a test, that checks the intended effect, and that fails on master.

@mid1221213
mid1221213 marked this pull request as ready for review March 30, 2025 12:34
@spytheman
spytheman merged commit a427fc5 into vlang:master Apr 1, 2025
@mid1221213
mid1221213 deleted the fix-type-alias-not-supported-in-orm branch April 1, 2025 07:13
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