Skip to content

orm: dynamic where block should support OR operator #27002

@Jengro777

Description

@Jengro777

Describe the feature

Current situation
In dynamic where block, comma means AND:

sql db {
    dynamic update User set name = 'new' where {
        id == user_id,
        tenant_id == tenant_id
    }
}
// WHERE id = ? AND tenant_id = ?

Problem
No way to write OR directly:

// ❌ Doesn't work
sql db {
    dynamic update User set name = 'new' where {
        id == user_id || tenant_id == tenant_id
    }
}

Use Case

Support || or or in dynamic where block:

	up_expr := {
		if status := req.status { status == status },
		if name := req.name { name == name },
		updated_at == time.now()
	}

sql db {
    dynamic update User set up_expr  where {
        id == user_id || tenant_id == tenant_id
    }
}
// WHERE id = ? OR tenant_id = ?

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.5.1 a2be374

Environment details (OS name and version, etc.)

V full version V 0.5.1 8ef799c.a2be374
OS linux, Deepin 25
Processor 20 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i5-13500
Memory 12.17GB/31.03GB
V executable /home/Jengro/opt/v/v
V last modified time 2026-04-27 00:53:44
V home dir OK, value: /home/Jengro/opt/v
VMODULES OK, value: /home/Jengro/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/Jengro
Git version git version 2.51.0
V git status 0.5.1-1390-ga2be3749
.git/config present true
cc version cc (Deepin 12.3.0-17deepin17) 12.3.0
gcc version gcc (Deepin 12.3.0-17deepin17) 12.3.0
clang version Deepin clang version 17.0.6 (5deepin7)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Debian GLIBC 2.38-6deepin21) 2.38

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions