diff options
| author | Shulhan <ms@kilabit.info> | 2024-01-27 02:45:22 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-01-27 03:07:32 +0700 |
| commit | 24269c23942843c8193998a75882e22111c333ac (patch) | |
| tree | 1b4395c590645852ef2c2416f047d2fcc27f775e /lib/sql/sql.go | |
| parent | c35eafe48695c6b8de34ebd6b64c4afa28940f34 (diff) | |
| download | pakakeh.go-24269c23942843c8193998a75882e22111c333ac.tar.xz | |
lib/sql: support update, bind where condition, and subquery in Meta
This changes add parameter kind to NewMeta, which define the kind of
DML to be mapped by Meta.
The method Add renamed to Bind, and AddWhere renamed to BindWhere.
New methods added to Meta,
- Sub return the child of Meta for building subquery,
- UpdateValues return the merged of ListValue and ListWhereValue
for DML UPDATE
- WhereFields return string that merge the ListWhereCond and ListHolder
separated by "="
Diffstat (limited to 'lib/sql/sql.go')
| -rw-r--r-- | lib/sql/sql.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sql/sql.go b/lib/sql/sql.go index bac782c5..3a76353d 100644 --- a/lib/sql/sql.go +++ b/lib/sql/sql.go @@ -15,3 +15,12 @@ const ( // DefaultPlaceHolder define default placeholder for DML, which is // placeholder for MySQL. const DefaultPlaceHolder = "?" + +// JoinValues join list of slice of values into single slice. +func JoinValues(s ...[]any) (all []any) { + var sub []any + for _, sub = range s { + all = append(all, sub...) + } + return all +} |
