feat(journal): accept PRAGMA queries
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
1c92e47b24
commit
7d3b62086d
2 changed files with 21 additions and 1 deletions
|
|
@ -123,7 +123,8 @@ func isRawSQLJournalQuery(query string) bool {
|
|||
upperQuery := core.Upper(core.Trim(query))
|
||||
return core.HasPrefix(upperQuery, "SELECT") ||
|
||||
core.HasPrefix(upperQuery, "WITH") ||
|
||||
core.HasPrefix(upperQuery, "EXPLAIN")
|
||||
core.HasPrefix(upperQuery, "EXPLAIN") ||
|
||||
core.HasPrefix(upperQuery, "PRAGMA")
|
||||
}
|
||||
|
||||
func (storeInstance *Store) queryJournalRows(query string, arguments ...any) core.Result {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,25 @@ func TestJournal_QueryJournal_Good_RawSQLWithCTE(t *testing.T) {
|
|||
assert.Equal(t, "session-a", rows[0]["measurement"])
|
||||
}
|
||||
|
||||
func TestJournal_QueryJournal_Good_PragmaSQL(t *testing.T) {
|
||||
storeInstance, err := New(":memory:", WithJournal("http://127.0.0.1:8086", "core", "events"))
|
||||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
rows := requireResultRows(
|
||||
t,
|
||||
storeInstance.QueryJournal("PRAGMA table_info(journal_entries)"),
|
||||
)
|
||||
require.NotEmpty(t, rows)
|
||||
var columnNames []string
|
||||
for _, row := range rows {
|
||||
name, ok := row["name"].(string)
|
||||
require.True(t, ok, "unexpected column name type: %T", row["name"])
|
||||
columnNames = append(columnNames, name)
|
||||
}
|
||||
assert.Contains(t, columnNames, "bucket_name")
|
||||
}
|
||||
|
||||
func TestJournal_QueryJournal_Good_FluxFilters(t *testing.T) {
|
||||
storeInstance, err := New(":memory:", WithJournal("http://127.0.0.1:8086", "core", "events"))
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue