From 78095c78e7b6abf12bae83bffb54b912d9ea516f Mon Sep 17 00:00:00 2001 From: shellfly Date: Thu, 20 Apr 2023 09:03:44 +0800 Subject: [PATCH] feat: support sqlite view --- pkg/log/log.go | 2 ++ pkg/sql/helper_my.go | 2 +- pkg/sql/helper_sqlite.go | 2 +- pkg/sql/urlquery.go | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/log/log.go b/pkg/log/log.go index 96995db..6c39df5 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -29,6 +29,8 @@ var ( func init() { //nolint:gochecknoinits level := os.Getenv("REST_LOG_LEVEL") switch strings.ToLower(level) { + case "trace": + logLevel = TraceLevel case "error": logLevel = ErrorLevel case "warn": diff --git a/pkg/sql/helper_my.go b/pkg/sql/helper_my.go index df12192..6fa6c8a 100644 --- a/pkg/sql/helper_my.go +++ b/pkg/sql/helper_my.go @@ -8,7 +8,7 @@ func (h MyHelper) GetTablesSQL() string { return ` SELECT TABLE_NAME as name FROM information_schema.TABLES - WHERE TABLE_TYPE LIKE 'BASE_TABLE' AND TABLE_SCHEMA=DATABASE(); + WHERE (TABLE_TYPE = 'BASE_TABLE' OR TABLE_TYPE = 'view') AND TABLE_SCHEMA=DATABASE(); ` } diff --git a/pkg/sql/helper_sqlite.go b/pkg/sql/helper_sqlite.go index aeaeb00..c5714c4 100644 --- a/pkg/sql/helper_sqlite.go +++ b/pkg/sql/helper_sqlite.go @@ -11,7 +11,7 @@ func (h SQLiteHelper) GetTablesSQL() string { FROM sqlite_schema WHERE - type ='table' AND + (type ='table' OR type = 'view') AND name NOT LIKE 'sqlite_%'; ` } diff --git a/pkg/sql/urlquery.go b/pkg/sql/urlquery.go index 016a359..3f46437 100644 --- a/pkg/sql/urlquery.go +++ b/pkg/sql/urlquery.go @@ -19,6 +19,7 @@ var ( // date functions "date", "date_format", "date_part", "date_trunc", "extract", "hour", "minute", "month", "second", "utctimestamp", "weekofday", "year", + "time", "datetime", "julianday", "unixepoch", "strftime", // string functions "bit_length", "chr", "char_length", "left", "length", "ord", "trim", }