Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
07336f03
Commit
07336f03
authored
Feb 05, 2025
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update condition concat check
parent
64dfadb5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
6 deletions
+20
-6
memo.go
store/db/mysql/memo.go
+5
-2
memo.go
store/db/postgres/memo.go
+5
-2
memo.go
store/db/sqlite/memo.go
+5
-2
memo_filter_test.go
store/db/sqlite/memo_filter_test.go
+5
-0
No files found.
store/db/mysql/memo.go
View file @
07336f03
...
@@ -121,8 +121,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -121,8 +121,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
convertCtx
.
Buffer
.
String
()))
condition
:=
convertCtx
.
Buffer
.
String
()
args
=
append
(
args
,
convertCtx
.
Args
...
)
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
having
=
append
(
having
,
"`parent_id` IS NULL"
)
having
=
append
(
having
,
"`parent_id` IS NULL"
)
...
...
store/db/postgres/memo.go
View file @
07336f03
...
@@ -113,8 +113,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -113,8 +113,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
convertCtx
.
Buffer
.
String
()))
condition
:=
convertCtx
.
Buffer
.
String
()
args
=
append
(
args
,
convertCtx
.
Args
...
)
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
where
=
append
(
where
,
"memo_relation.related_memo_id IS NULL"
)
where
=
append
(
where
,
"memo_relation.related_memo_id IS NULL"
)
...
...
store/db/sqlite/memo.go
View file @
07336f03
...
@@ -113,8 +113,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -113,8 +113,11 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
convertCtx
.
Buffer
.
String
()))
condition
:=
convertCtx
.
Buffer
.
String
()
args
=
append
(
args
,
convertCtx
.
Args
...
)
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
where
=
append
(
where
,
"`parent_id` IS NULL"
)
where
=
append
(
where
,
"`parent_id` IS NULL"
)
...
...
store/db/sqlite/memo_filter_test.go
View file @
07336f03
...
@@ -54,6 +54,11 @@ func TestConvertExprToSQL(t *testing.T) {
...
@@ -54,6 +54,11 @@ func TestConvertExprToSQL(t *testing.T) {
want
:
"(JSON_EXTRACT(`memo`.`payload`, '$.tags') LIKE ? OR `memo`.`content` LIKE ?)"
,
want
:
"(JSON_EXTRACT(`memo`.`payload`, '$.tags') LIKE ? OR `memo`.`content` LIKE ?)"
,
args
:
[]
any
{
`%"tag1"%`
,
"%hello%"
},
args
:
[]
any
{
`%"tag1"%`
,
"%hello%"
},
},
},
{
filter
:
`1`
,
want
:
""
,
args
:
[]
any
{},
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment