fix: major bug audit + fixes — honest PLAN.md
Critical bugs fixed: - SELECT now returns actual row data (was returning empty arrays) - WHERE filter evaluation now works (was pass-through stub) - ORDER BY sorting now works (was no-op) - UPDATE execution implemented (was no-op stub) - DELETE uses WHERE filter (was key-match only) - B-Tree point reads return actual row data (was returning count only) - EXPLAIN returns plan string (was computed then discarded) - UNIQUE constraint uses B-Tree index (was memtable scan only) - DEFAULT values work for int/bool/float (was string-only) - HTTP /query returns real JSON rows with columns - Docker healthcheck uses wget (Alpine has no curl) Updated PLAN.md with honest status: - Marked what's truly done vs stub vs not implemented - Honest score: 8/10 (not 9.5/10) - Clear list of what actually works in production All 216 tests pass
This commit is contained in:
@@ -70,21 +70,22 @@ proc executeQuery(db: LSMTree, ctx: ExecutionContext, query: string): (bool, Que
|
||||
if astNode.stmts.len == 0:
|
||||
return (true, QueryResult(), "")
|
||||
|
||||
let stmt = astNode.stmts[0]
|
||||
case stmt.kind
|
||||
of nkSelect, nkInsert, nkUpdate, nkDelete, nkCreateTable, nkDropTable,
|
||||
nkCreateType, nkBeginTxn, nkCommitTxn, nkRollbackTxn, nkExplainStmt:
|
||||
let (success, errMsg, affectedRows) = executor.executeQuery(ctx, astNode)
|
||||
if success:
|
||||
var qr = QueryResult(affectedRows: affectedRows, rowCount: affectedRows)
|
||||
if stmt.kind == nkSelect:
|
||||
qr.columns = @["key", "value"]
|
||||
qr.rows = @[]
|
||||
return (true, qr, "")
|
||||
else:
|
||||
return (false, QueryResult(), errMsg)
|
||||
let result = executor.executeQuery(ctx, astNode)
|
||||
if result.success:
|
||||
var qr = QueryResult(affectedRows: result.affectedRows, rowCount: result.rows.len)
|
||||
qr.columns = result.columns
|
||||
qr.rows = @[]
|
||||
for row in result.rows:
|
||||
var wireRow: seq[WireValue] = @[]
|
||||
for col in result.columns:
|
||||
if col in row:
|
||||
wireRow.add(WireValue(kind: fkString, strVal: row[col]))
|
||||
else:
|
||||
wireRow.add(WireValue(kind: fkString, strVal: ""))
|
||||
qr.rows.add(wireRow)
|
||||
return (true, qr, result.message)
|
||||
else:
|
||||
return (false, QueryResult(), "Unsupported statement type: " & $stmt.kind)
|
||||
return (false, QueryResult(), result.message)
|
||||
except Exception as e:
|
||||
return (false, QueryResult(), e.msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user