Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: calendar filter (#4942)

Colin Holzmanaae7ec8d1f67
diff --git a/plugin/filter/dialect.go b/plugin/filter/dialect.go
index 98ad1538c..41adc2ffe 100644
--- a/plugin/filter/dialect.go
+++ b/plugin/filter/dialect.go
@@ -222,7 +222,7 @@ func (d *PostgreSQLDialect) GetBooleanCheck(path string) string {
}
func (d *PostgreSQLDialect) GetTimestampComparison(field string) string {
- return fmt.Sprintf("EXTRACT(EPOCH FROM %s.%s)", d.GetTablePrefix(), field)
+ return fmt.Sprintf("EXTRACT(EPOCH FROM TO_TIMESTAMP(%s.%s))", d.GetTablePrefix(), field)
}
func (*PostgreSQLDialect) GetCurrentTimestamp() string {
diff --git a/store/db/postgres/memo_filter_test.go b/store/db/postgres/memo_filter_test.go
index 0ecb48ac8..2ee804e15 100644
--- a/store/db/postgres/memo_filter_test.go
+++ b/store/db/postgres/memo_filter_test.go
@@ -92,7 +92,7 @@ func TestConvertExprToSQL(t *testing.T) {
},
{
filter: `created_ts > now() - 60 * 60 * 24`,
- want: "EXTRACT(EPOCH FROM memo.created_ts) > $1",
+ want: "EXTRACT(EPOCH FROM TO_TIMESTAMP(memo.created_ts)) > $1",
args: []any{time.Now().Unix() - 60*60*24},
},
{