mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-21 02:36:49 +00:00
* fix(sqlite): use github.com/hanzoai/sqlite, never modernc directly object/adapter.go and the two cmd/ tools blank-imported modernc.org/sqlite to register the database/sql "sqlite" driver. That is the ONLY direct modernc importer in ai — and when ai is linked into a binary that also links github.com/hanzoai/sqlite (hanzoai/cloud, via #96), a CGO_ENABLED=1 build registers "sqlite" twice (mattn in the fork + modernc here) and panics at init. Route all three through the ONE Hanzo driver, github.com/hanzoai/sqlite, which registers "sqlite" exactly once per build (cgo→SQLCipher, !cgo→modernc). No behavior change: ai ships CGO_ENABLED=0, where the fork IS modernc. * style(split): gofumpt -w split/code.go (v0.10.0 map alignment) Pre-existing gofumpt v0.10.0 alignment drift unrelated to the sqlite change; required Go-Linter check flags it. Pure formatting, no logic change.
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
_ "github.com/hanzoai/sqlite" // ONE Hanzo sqlite driver (cgo→SQLCipher, !cgo→modernc); never import modernc directly
|
|
)
|
|
|
|
func main() {
|
|
db, _ := sql.Open("sqlite", "file:/tmp/cloud-staging.db?mode=ro&_journal_mode=OFF")
|
|
rows, _ := db.Query("SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name")
|
|
for rows.Next() {
|
|
var n, sqlStr string
|
|
rows.Scan(&n, &sqlStr)
|
|
fmt.Printf("=== %s ===\n%s\n\n", n, sqlStr)
|
|
}
|
|
for _, t := range []string{"application", "record", "provider", "store", "template"} {
|
|
var c int
|
|
db.QueryRow(fmt.Sprintf("SELECT COUNT(*) FROM \"%s\"", t)).Scan(&c)
|
|
fmt.Printf("rows in %s: %d\n", t, c)
|
|
}
|
|
}
|