[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #91
2 changed files with 33 additions and 1 deletions
|
|
@ -108,7 +108,7 @@ func (storeInstance *Store) QueryJournal(flux string) core.Result {
|
|||
"SELECT bucket_name, measurement, fields_json, tags_json, committed_at, archived_at FROM " + journalEntriesTableName + " WHERE archived_at IS NULL ORDER BY committed_at",
|
||||
)
|
||||
}
|
||||
if core.HasPrefix(trimmedQuery, "SELECT") || core.HasPrefix(trimmedQuery, "select") {
|
||||
if isRawSQLJournalQuery(trimmedQuery) {
|
||||
return storeInstance.queryJournalRows(trimmedQuery)
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +119,13 @@ func (storeInstance *Store) QueryJournal(flux string) core.Result {
|
|||
return storeInstance.queryJournalRows(selectSQL, arguments...)
|
||||
}
|
||||
|
||||
func isRawSQLJournalQuery(query string) bool {
|
||||
upperQuery := core.Upper(core.Trim(query))
|
||||
return core.HasPrefix(upperQuery, "SELECT") ||
|
||||
core.HasPrefix(upperQuery, "WITH") ||
|
||||
core.HasPrefix(upperQuery, "EXPLAIN")
|
||||
}
|
||||
|
||||
func (storeInstance *Store) queryJournalRows(query string, arguments ...any) core.Result {
|
||||
rows, err := storeInstance.database.Query(query, arguments...)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,31 @@ func TestJournal_CommitToJournal_Good_WithQueryJournalSQL(t *testing.T) {
|
|||
assert.Equal(t, "session-b", tags["workspace"])
|
||||
}
|
||||
|
||||
func TestJournal_QueryJournal_Good_RawSQLWithCTE(t *testing.T) {
|
||||
storeInstance, err := New(":memory:", WithJournal("http://127.0.0.1:8086", "core", "events"))
|
||||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
require.True(t,
|
||||
storeInstance.CommitToJournal("session-a", map[string]any{"like": 4}, map[string]string{"workspace": "session-a"}).OK,
|
||||
)
|
||||
|
||||
rows := requireResultRows(
|
||||
t,
|
||||
storeInstance.QueryJournal(`
|
||||
WITH journal_rows AS (
|
||||
SELECT bucket_name, measurement, fields_json, tags_json, committed_at, archived_at
|
||||
FROM journal_entries
|
||||
)
|
||||
SELECT bucket_name, measurement, fields_json, tags_json, committed_at, archived_at
|
||||
FROM journal_rows
|
||||
ORDER BY committed_at
|
||||
`),
|
||||
)
|
||||
require.Len(t, rows, 1)
|
||||
assert.Equal(t, "session-a", rows[0]["measurement"])
|
||||
}
|
||||
|
||||
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