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: segfault when having nested foreign keys #18324

Closed
mak3e opened this issue Jun 1, 2023 · 2 comments · Fixed by #20774
Closed

orm: segfault when having nested foreign keys #18324

mak3e opened this issue Jun 1, 2023 · 2 comments · Fixed by #20774
Labels
Bug This tag is applied to issues which reports bugs. ORM Bugs/feature requests, that are related to the V ORM.

Comments

@mak3e
Copy link

mak3e commented Jun 1, 2023

Describe the bug

If I define a foreign key relation to a table that has foreign key relation of its own the code compiles but results a runtime segfault even without a database connection.

Expected Behavior

No segfault

Current Behavior

signal 11: segmentation fault

Reproduction Steps

module main

import db.pg

[table: 'example']
pub struct Example {
    id        int        [primary; sql: serial]
    example2s []Example2 [fkey: 'example_id']
}

[table: 'example2']
pub struct Example2 {
    id         int        [primary; sql: serial]
    example_id int
    example3s  []Example3 [fkey: 'example2_id']
}

[table: 'example3']
pub struct Example3 {
    id          int [primary; sql: serial]
    example2_id int
}

fn main() {
    db := pg.connect(pg.Config{}) or { exit(0) }
    sql db {
        create table Example3
        create table Example2
        create table Example
    } or { print(err) }
}

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.3.4 a647a71

Environment details (OS name and version, etc.)

V full version: V 0.3.4 a938dcd.a647a71
OS: linux, "Gentoo Linux"
Processor: 16 cpus, 64bit, little endian, Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz

getwd: /home/make
vexe: /home/make/v/v
vexe mtime: 2023-05-30 18:54:28

vroot: OK, value: /home/make/v
VMODULES: OK, value: /home/make/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.40.1
Git vroot status: weekly.2023.21-53-ga647a71c
.git/config present: true

CC version: cc (Gentoo 13.1.1_p20230527 p3) 13.1.1 20230527
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

@mak3e mak3e added the Bug This tag is applied to issues which reports bugs. label Jun 1, 2023
@JalonSolov JalonSolov assigned ghost Jun 1, 2023
@felipensp felipensp added the ORM Bugs/feature requests, that are related to the V ORM. label Jun 1, 2023
@ghost ghost removed their assignment Nov 27, 2023
@nkoehring
Copy link

Got the same issue and I wonder if there is a fix planned already?

@spytheman
Copy link
Member

#20774 fixes the compilation of this example.

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
4 participants