Skip to content
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

[orm] build error with ?[]Child #20014

Closed
smichea opened this issue Nov 28, 2023 · 0 comments · Fixed by #20032
Closed

[orm] build error with ?[]Child #20014

smichea opened this issue Nov 28, 2023 · 0 comments · Fixed by #20032
Labels
Bug This tag is applied to issues which reports bugs. ORM Bugs/feature requests, that are related to the V ORM.

Comments

@smichea
Copy link

smichea commented Nov 28, 2023

Describe the bug

When having an entity that has a list of child, like

@[table: 'todolist']
pub struct TodoList {
    uuid string @[primary]
    todoitems ?[]TodoItem @[fkey:todolist]
    creationdate string @[default: 'CURRENT_TIMESTAMP';sql_type: 'TIMESTAMP']
    active ?bool 
    name string 
}

the build process throw the error

tmp/v_1000/mvtodolist.17075409489401821847.tmp.c:23730: error: field not found: len

which correspond to
image

Reproduction Steps

run the file

import db.pg

struct Member{
    id int @[primary]
    children ?[]Child @[fkey:parent_id]
}

struct Child{
	id int @[primary]
	parent_id int
}

fn main() {
	db := pg.connect(pg.Config{
		host: 'localhost' 
		user: 'meveo'
		password: 'meveo'
		dbname: 'meveo'
	}) or {
		println('failed to connect')
		println(err)
		return
	}
	sql db { create table Member } or {
		println(err)
	}
	new_member := Member{
		id: 1
		children: [Child{
			id: 1
			parent_id: 1
		}]
	}
	sql db { insert new_member into Member}!
}

Expected Behavior

either no error or an error at compilation time telling the ? should not be used with array of entities

Current Behavior

builder error :

$ v run testBug.v 
==================
/tmp/v_1000/testBug.6130289918847203090.tmp.c:18224: error: field not found: len
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 b5ba122

Environment details (OS name and version, etc.)

ubuntu 22.04.2 in wsl2 (win 11)

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@smichea smichea added the Bug This tag is applied to issues which reports bugs. label Nov 28, 2023
@felipensp felipensp added the ORM Bugs/feature requests, that are related to the V ORM. label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. ORM Bugs/feature requests, that are related to the V ORM.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants