chore: rename genji to chai

This commit is contained in:
Asdine El Hrychy
2023-12-02 11:25:56 +04:00
parent 1d31be550c
commit edcb91d4c5
235 changed files with 1153 additions and 1168 deletions

View File

@@ -1,55 +1,47 @@
# Contributing
You can participate in Genji in several ways, there is so much to do to make this project awesome!
Below, you'll find guidelines on how to contribute effectively.
- [Reporting a bug](#reporting-a-bug)
- [Proposing an SQL feature or a general design change](#proposing-an-sql-feature-or-a-general-design-change)
- [Other contributions](#other-contributions)
## Ways to Contribute
The goal of this document is to provide guidelines to contributors to make working with Genji a smooth experience.
Genji is a complex project that has many moving parts and we want to make sure that everyone's working towards the same goal.
There are several ways you can contribute to Chai:
We want to avoid situations where you would put energy on a contribution that gets rejected because it doesn't match the direction
this project is taking.
### Reporting a Bug
## Reporting a bug
If you encounter a bug while using Chai, please help us by reporting it. To do so, follow these steps:
We use Github issues to track bugs. Report a bug by [opening an issue](https://github.com/genjidb/genji/issues/new), it's that easy!
- Open a new issue.
- Provide essential information:
- Chai version you are using
- Detailed description of the observed behavior
- Description of the expected behavior
- If possible, include code examples or a link to a Go playground illustrating the issue.
Make sure you give enough context for us to reproduce the bug:
### Proposing an SQL Feature or Design Change
- The version of Genji you are using
- The observed behavior
- The expected behavior
- Ideally, some code like a main file or a Go [playground](https://play.golang.org/) link
If you have an idea for an SQL feature or a significant design change, we appreciate your input. To propose such a change, follow these steps:
## Proposing an SQL feature or a general design change
- Open an issue to describe the SQL feature or design change you'd like to propose.
- Engage in a discussion with the project maintainers and contributors to refine your proposal.
- If necessary, an RFC (Request for Comments) document will be created to document the proposal in detail.
- Once the proposal is accepted, a designated contributor will create a Pull Request (PR) to implement it.
Genji is not a common database because it mixes documents with SQL. Some SQL features that make sense in mainstream relational databases may not be a good fit for this project and vice versa.
Every feature can have a big impact on the project, including performance, ordering, encoding, etc.
To propose a consistent solution to users, every SQL feature needs to be thoroughly designed and discussed before even starting implementing it.
Please note that the level of involvement in the RFC and PR process may vary depending on the complexity and significance of the feature. We encourage everyone to contribute and will try to accommodate your contributions.
- Open an issue describing the SQL feature you want Genji to include
- Discuss it with maintainers and contributors
- If necessary, someone will be in charge of writing an RFC
- Once the feature is accepted, someone will be in charge of creating a Pull Request
### Other Contributions
Depending on the complexity and importance of the feature, the RFC and the PR may or may not be assigned to you. However, we will always do our best to let you contribute code if you are eager to do so and the feature doesn't require too much context.
Chai can benefit from various contributions beyond bug reports and feature proposals. You can contribute by:
## Other contributions
- Improving Continuous Integration (CI) and tooling.
- Enhancing Go APIs.
- Updating documentation.
- Adding support for new build targets.
- Improving performance.
Anything that can help improve Genji is a welcome contribution. Here are a few examples of things that can be improved:
To contribute in these areas, follow these general steps:
- CI/Tooling
- Go APIs
- Documentation
- Build targets support
- Performance
- Open an issue to discuss your proposed contribution.
- Collaborate with project maintainers and contributors to plan and refine your solution.
- Open a Pull Request (PR) to propose your solution to the problem.
In most cases, contributing to Genji must follow these guidelines:
- Open an issue
- Discuss with maintainers and contributors
- Open a PR to propose your solution to the problem
If the change is really small, like correcting a typo or a very obvious bug fix, you may open a PR directly.
For minor changes like straightforward bug fixes, you may directly open a PR.

View File

@@ -6,10 +6,10 @@ labels: bug
<!-- Please answer these questions before submitting your issue. Thanks! -->
### What version of Genji are you using?
### What version of Chai are you using?
<pre>
$ genji version
$ chai version
</pre>
@@ -18,8 +18,7 @@ $ genji version
<!--
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org or goplay.space is best. You may use
https://play.golang.org/p/_pr_rOXsAH3 as a starting point.
A link on play.golang.org or goplay.space is best.
-->
### What did you expect to see?

View File

@@ -9,7 +9,7 @@ labels: enhancement
### Proposal
<!--
What is the current status of the proposed behavior? E.g. “Currently, its not possible to do X in Genji”.
What is the current status of the proposed behavior? E.g. “Currently, its not possible to do X in Chai”.
What is the proposed solution? E.g. “I propose adding SQL syntax Y that does X”.
-->

View File

@@ -30,11 +30,11 @@ jobs:
- name: Install go-acc
run: go install github.com/ory/go-acc@latest
- name: Test Genji
- name: Test Chai
run: go-acc $(go list ./...) -- -mod vendor -race -timeout=2m
- name: Test Genji CLI
run: cd ./cmd/genji && go test -race ./... && cd -
- name: Test Chai CLI
run: cd ./cmd/chai && go test -race ./... && cd -
- name: Upload Codecov
run: bash <(curl -s https://codecov.io/bash)

2
.gitignore vendored
View File

@@ -27,7 +27,7 @@ profile.*
*.csv
# Builds
cmd/genji/genji
cmd/chai/chai
# IDE config
.vscode/

View File

@@ -1,4 +1,4 @@
NAME := genji
NAME := chai
.PHONY: all build $(NAME) gen test testrace bench tidy
@@ -14,16 +14,16 @@ gen:
test:
go test -timeout=1m -cover ./...
cd cmd/genji && go test -cover -timeout=1m ./...
cd cmd/chai && go test -cover -timeout=1m ./...
testrace:
go test -race -cover -timeout=1m ./...
cd cmd/genji && go test -race -cover -timeout=1m ./...
cd cmd/chai && go test -race -cover -timeout=1m ./...
bench:
go test -v -run=^\$$ -benchmem -bench=. ./...
cd cmd/genji && go test -v -run=^\$$ -benchmem -bench=. ./...
cd cmd/chai && go test -v -run=^\$$ -benchmem -bench=. ./...
tidy:
go mod tidy
cd cmd/genji && go mod tidy && cd ../..
cd cmd/chai && go mod tidy && cd ../..

View File

@@ -1,20 +1,18 @@
<h1 align="center"> ChaiSQL </h1>
<p align="center">
<a href="https://chai.dev">
<img alt="chaiSQL" title="chaiSQL" src="https://raw.githubusercontent.com/chaisql/docs/master/assets/icons/logo.svg?sanitize=true" width="100">
<img alt="ChaiSQL" title="ChaiSQL" src="https://raw.githubusercontent.com/chaisql/docs/master/assets/icons/logo.svg?sanitize=true" width="100">
</a>
</p>
<p align="center">
ChaiSQL is a modern embedded SQL database, focusing on flexibility and ease of use for developers. It provides a fresh alternative to traditional SQL databases by supporting more flexible schemas and offering advanced features tailored for modern applications.
ChaiSQL is a modern embedded SQL database, focusing on flexibility and ease of use for developers. It provides a fresh alternative to traditional SQL databases by offering advanced features tailored for modern applications.
</p>
[![Build Status](https://github.com/chaisql/chai/actions/workflows/go.yml/badge.svg)](https://github.com/chaisql/chai/actions/workflows/go.yml)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/chaisql/chai)
![Status](https://img.shields.io/badge/status-alpha-yellow)
## Key Features
- **Modern SQL Experience**: ChaiSQL introduces a modern twist to SQL, offering enhanced features and performance optimizations.
@@ -115,7 +113,7 @@ func main() {
> :warning: Chai's API is still evolving: We are working towards the v1.0.0 release, which will bring stability to the database structure and API.
Checkout the [SQL documentation](https://chai.dev/docs/essentials/sql-introduction/), the [Go doc](https://pkg.go.dev/github.com/chaisql/chai) and the [usage example](#usage) in the README to get started quickly.
Checkout the [SQL documentation](https://chaisql.com/docs/essentials/sql-introduction/), the [Go doc](https://pkg.go.dev/github.com/chaisql/chai) and the [usage example](#usage) in the README to get started quickly.
### In-memory database

View File

@@ -6,16 +6,16 @@ import (
"os/signal"
"syscall"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/genjidb/genji/cmd/genji/shell"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/chaisql/chai/cmd/chai/shell"
"github.com/urfave/cli/v2"
)
// NewApp creates the Genji CLI app.
// NewApp creates the Chai CLI app.
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = "Genji"
app.Usage = "Shell for the Genji database"
app.Name = "chai"
app.Usage = "Shell for the ChaiSQL database"
app.EnableBashCompletion = true
app.Commands = []*cli.Command{

View File

@@ -3,20 +3,20 @@ package commands
import (
"errors"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/urfave/cli/v2"
)
// NewBenchCommand returns a cli.Command for "genji bench".
// NewBenchCommand returns a cli.Command for "chai bench".
func NewBenchCommand() *cli.Command {
cmd := cli.Command{
Name: "bench",
Usage: "Simple load testing command",
UsageText: `genji bench query`,
UsageText: `chai bench query`,
Description: `The bench command runs a query repeatedly (100 times by default, -n option) and outputs a series of results.
Each result represent the average time for a given sample of queries (10 by default, -s/--sample option).
$ genji bench -n 200 -s 5 "SELECT 1"
$ chai bench -n 200 -s 5 "SELECT 1"
{
"totalQueries": 5,
"sampleSpeed": "2.191µs"
@@ -35,11 +35,11 @@ $ genji bench -n 200 -s 5 "SELECT 1"
By default, queries are run in-memory. To write them on disk, use the -p/--path options.
The database will be created if it doesn't exist.
$ genji bench -p mydb/ "SELECT 1"
$ chai bench -p mydb/ "SELECT 1"
To prepare the database before running a query, use the -i/--init option
$ genji bench -p "CREATE TABLE foo; INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo"
$ chai bench -p "CREATE TABLE foo; INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo"
By default, each query is run in a separate transaction. To run everything, including the setup,
in the same transaction, use -t`,

View File

@@ -4,32 +4,32 @@ import (
"io"
"os"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/urfave/cli/v2"
)
// NewDumpCommand returns a cli.Command for "genji dump".
// NewDumpCommand returns a cli.Command for "chai dump".
func NewDumpCommand() *cli.Command {
cmd := cli.Command{
Name: "dump",
Usage: "Dump a database or a list of tables as a text file.",
UsageText: `genji dump [options] dbpath`,
UsageText: `chai dump [options] dbpath`,
Description: `The dump command can dump a database as a text file.
By default, the content of the database is sent to the standard output:
$ genji dump my.db
$ chai dump my.db
CREATE TABLE foo;
...
It is possible to specify a list of tables to output:
$ genji dump -t foo -f bar my.db
$ chai dump -t foo -f bar my.db
The dump command can also write directly into a file:
$ genji dump -f dump.sql my.db`,
$ chai dump -f dump.sql my.db`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "file",

View File

@@ -10,38 +10,38 @@ import (
"github.com/cockroachdb/errors"
"github.com/urfave/cli/v2"
"github.com/genjidb/genji"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/chaisql/chai"
"github.com/chaisql/chai/cmd/chai/dbutil"
)
// NewInsertCommand returns a cli.Command for "genji insert".
// NewInsertCommand returns a cli.Command for "chai insert".
func NewInsertCommand() *cli.Command {
return &cli.Command{
Name: "insert",
Usage: "Insert objects from arguments or standard input",
UsageText: "genji insert [options] [json...]",
UsageText: "chai insert [options] [json...]",
Description: `
The insert command inserts objects into an existing table.
Insert can take JSON objects as separate arguments:
$ genji insert --db mydb -t foo '{"a": 1}' '{"a": 2}'
$ chai insert --db mydb -t foo '{"a": 1}' '{"a": 2}'
It is also possible to pass an array of objects:
$ genji insert --db mydb -t foo '[{"a": 1}, {"a": 2}]'
$ chai insert --db mydb -t foo '[{"a": 1}, {"a": 2}]'
Also you can use -a flag to create database automatically.
This example will create a database with name 'data_${current unix timestamp}'
It can be combined with --db to select an existing database but automatically create the table.
$ genji insert -a '[{"a": 1}, {"a": 2}]'
$ chai insert -a '[{"a": 1}, {"a": 2}]'
Insert can also insert a stream of objects or an array of objects from standard input:
$ echo '{"a": 1} {"a": 2}' | genji insert --db mydb -t foo
$ echo '[{"a": 1},{"a": 2}]' | genji insert --db mydb -t foo
$ curl https://api.github.com/repos/genjidb/genji/issues | genji insert --db mydb -t foo`,
$ echo '{"a": 1} {"a": 2}' | chai insert --db mydb -t foo
$ echo '[{"a": 1},{"a": 2}]' | chai insert --db mydb -t foo
$ curl https://api.github.com/repos/chaidb/chai/issues | chai insert --db mydb -t foo`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "db",
@@ -101,7 +101,7 @@ func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args
return nil
}
func insert(db *genji.DB, table string, createTable bool, args ...string) error {
func insert(db *chai.DB, table string, createTable bool, args ...string) error {
if createTable {
err := db.Exec("CREATE TABLE " + table)
if err != nil {

View File

@@ -1,16 +1,16 @@
package commands
import (
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/urfave/cli/v2"
)
// NewPebbleCommand returns a cli.Command for "genji pebble".
// NewPebbleCommand returns a cli.Command for "chai pebble".
func NewPebbleCommand() *cli.Command {
cmd := cli.Command{
Name: "pebble",
Usage: "Outputs the content of the Pebble database",
UsageText: `genji pebble`,
UsageText: `chai pebble`,
Description: `The pebble command simply outputs the content of the Pebble database in the standard output.`,
Flags: []cli.Flag{
&cli.StringFlag{

View File

@@ -1,20 +1,20 @@
package commands
import (
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/urfave/cli/v2"
)
// NewRestoreCommand returns a cli.Command for "genji restore".
// NewRestoreCommand returns a cli.Command for "chai restore".
func NewRestoreCommand() (cmd *cli.Command) {
return &cli.Command{
Name: "restore",
Usage: "Restore a database from a file created by genji dump",
UsageText: `genji restore dumpFile dbPath`,
Usage: "Restore a database from a file created by chai dump",
UsageText: `chai restore dumpFile dbPath`,
Description: `The restore command can restore a database from a text file.
$ genji restore dump.sql mydb`,
$ chai restore dump.sql mydb`,
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
args := c.Args()

View File

@@ -7,13 +7,13 @@ import (
"github.com/urfave/cli/v2"
)
// NewVersionCommand returns a cli.Command for "genji version".
// NewVersionCommand returns a cli.Command for "chai version".
func NewVersionCommand() *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Shows Genji and Genji CLI version",
Usage: "Shows Chai and Chai CLI version",
Action: func(c *cli.Context) error {
var cliVersion, genjiVersion string
var cliVersion, chaiVersion string
info, ok := debug.ReadBuildInfo()
if !ok {
@@ -23,18 +23,18 @@ func NewVersionCommand() *cli.Command {
cliVersion = info.Main.Version
for _, mod := range info.Deps {
if mod.Path != "github.com/genjidb/genji" {
if mod.Path != "github.com/chaisql/chai" {
continue
}
// if a replace directive is set, Genji is in development mode
// if a replace directive is set, Chai is in development mode
if mod.Replace != nil {
genjiVersion = "(devel)"
chaiVersion = "(devel)"
break
}
genjiVersion = mod.Version
chaiVersion = mod.Version
break
}
fmt.Printf("Genji %v\nGenji CLI %v\n", genjiVersion, cliVersion)
fmt.Printf("Chai %v\nChai CLI %v\n", chaiVersion, cliVersion)
return nil
},
}

View File

@@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/genjidb/genji"
"github.com/chaisql/chai"
)
type BenchOptions struct {
@@ -22,15 +22,15 @@ type BenchOptions struct {
}
type preparer interface {
Prepare(q string) (*genji.Statement, error)
Prepare(q string) (*chai.Statement, error)
}
type execer func(q string, args ...interface{}) error
// Bench takes a database and dumps its content as SQL queries in the given writer.
// If tables is provided, only selected tables will be outputted.
func Bench(db *genji.DB, query string, opt BenchOptions) error {
var tx *genji.Tx
func Bench(db *chai.DB, query string, opt BenchOptions) error {
var tx *chai.Tx
var p preparer = db
var e execer = db.Exec
var err error

View File

@@ -3,16 +3,16 @@ package dbutil
import (
"context"
"github.com/genjidb/genji"
"github.com/chaisql/chai"
)
// OpenDB is a helper function that takes raw unvalidated parameters and opens a database.
func OpenDB(ctx context.Context, dbPath string) (*genji.DB, error) {
func OpenDB(ctx context.Context, dbPath string) (*chai.DB, error) {
if dbPath == "" {
dbPath = ":memory:"
}
db, err := genji.Open(dbPath)
db, err := chai.Open(dbPath)
if err != nil {
return nil, err
}

View File

@@ -4,13 +4,13 @@ import (
"fmt"
"io"
"github.com/genjidb/genji"
"github.com/chaisql/chai"
"go.uber.org/multierr"
)
// Dump takes a database and dumps its content as SQL queries in the given writer.
// If tables is provided, only selected tables will be outputted.
func Dump(db *genji.DB, w io.Writer, tables ...string) error {
func Dump(db *chai.DB, w io.Writer, tables ...string) error {
tx, err := db.Begin(false)
if err != nil {
return err
@@ -43,7 +43,7 @@ func Dump(db *genji.DB, w io.Writer, tables ...string) error {
}
// dumpTable displays the content of the given table as SQL statements.
func dumpTable(tx *genji.Tx, w io.Writer, query, tableName string) error {
func dumpTable(tx *chai.Tx, w io.Writer, query, tableName string) error {
// Dump schema first.
if err := dumpSchema(tx, w, query, tableName); err != nil {
return err
@@ -58,7 +58,7 @@ func dumpTable(tx *genji.Tx, w io.Writer, query, tableName string) error {
// Inserts statements.
insert := fmt.Sprintf("INSERT INTO %s VALUES", tableName)
return res.Iterate(func(r *genji.Row) error {
return res.Iterate(func(r *chai.Row) error {
data, err := r.MarshalJSON()
if err != nil {
return err
@@ -74,7 +74,7 @@ func dumpTable(tx *genji.Tx, w io.Writer, query, tableName string) error {
// DumpSchema takes a database and dumps its schema as SQL queries in the given writer.
// If tables are provided, only selected tables will be outputted.
func DumpSchema(db *genji.DB, w io.Writer, tables ...string) error {
func DumpSchema(db *chai.DB, w io.Writer, tables ...string) error {
tx, err := db.Begin(false)
if err != nil {
return err
@@ -96,7 +96,7 @@ func DumpSchema(db *genji.DB, w io.Writer, tables ...string) error {
}
// dumpSchema displays the schema of the given table as SQL statements.
func dumpSchema(tx *genji.Tx, w io.Writer, query string, tableName string) error {
func dumpSchema(tx *chai.Tx, w io.Writer, query string, tableName string) error {
_, err := fmt.Fprintf(w, "%s;\n", query)
if err != nil {
return err
@@ -104,7 +104,7 @@ func dumpSchema(tx *genji.Tx, w io.Writer, query string, tableName string) error
// Indexes statements.
res, err := tx.Query(`
SELECT sql FROM __genji_catalog WHERE
SELECT sql FROM __chai_catalog WHERE
type = 'index' AND owner.table_name = ? OR
type = 'sequence' AND owner IS NULL
`, tableName)
@@ -113,7 +113,7 @@ func dumpSchema(tx *genji.Tx, w io.Writer, query string, tableName string) error
}
defer res.Close()
return res.Iterate(func(r *genji.Row) error {
return res.Iterate(func(r *chai.Row) error {
var q string
err = r.Scan(&q)

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"testing"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)
@@ -21,7 +21,7 @@ func TestDump(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()

View File

@@ -5,16 +5,16 @@ import (
"encoding/json"
"io"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/query"
"github.com/genjidb/genji/internal/query/statement"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/query"
"github.com/chaisql/chai/internal/query/statement"
"github.com/chaisql/chai/internal/sql/parser"
)
// ExecSQL reads SQL queries from reader and executes them until the reader is exhausted.
// If the query has results, they will be outputted to w.
func ExecSQL(ctx context.Context, db *genji.DB, r io.Reader, w io.Writer) error {
func ExecSQL(ctx context.Context, db *chai.DB, r io.Reader, w io.Writer) error {
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")

View File

@@ -6,13 +6,13 @@ import (
"strings"
"testing"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)
func TestExecSQL(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()

View File

@@ -8,13 +8,13 @@ import (
"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/object"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/object"
)
// InsertJSON reads json objects from r and inserts them into the selected table.
// The reader can be either a stream of json objects or an array of objects.
func InsertJSON(db *genji.DB, table string, r io.Reader) error {
func InsertJSON(db *chai.DB, table string, r io.Reader) error {
tx, err := db.Begin(true)
if err != nil {
return err

View File

@@ -5,8 +5,8 @@ import (
"strings"
"testing"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)
@@ -28,7 +28,7 @@ func TestInsertJSON(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -67,7 +67,7 @@ func TestInsertJSON(t *testing.T) {
`{"Name": "Sam", "Text": "Go fmt who?"}`,
`{"Name": "Ed", "Text": "Go fmt yourself!"}`}
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -80,7 +80,7 @@ func TestInsertJSON(t *testing.T) {
assert.NoError(t, err)
i := 0
_ = res.Iterate(func(r *genji.Row) error {
_ = res.Iterate(func(r *chai.Row) error {
data, err := r.MarshalJSON()
assert.NoError(t, err)
require.JSONEq(t, jsonStreamResult[i], string(data))
@@ -102,7 +102,7 @@ func TestInsertJSON(t *testing.T) {
`{"Name": "Sam", "Text": "Go fmt who?"}`,
`{"Name": "Ed", "Text": "Go fmt yourself!"}`}
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
defer db.Close()
assert.NoError(t, err)
@@ -117,7 +117,7 @@ func TestInsertJSON(t *testing.T) {
assert.NoError(t, err)
i := 0
_ = res.Iterate(func(r *genji.Row) error {
_ = res.Iterate(func(r *chai.Row) error {
data, err := r.MarshalJSON()
assert.NoError(t, err)
require.JSONEq(t, jsonStreamResult[i], string(data))
@@ -126,7 +126,7 @@ func TestInsertJSON(t *testing.T) {
})
wantCount := 0
err = res.Iterate(func(r *genji.Row) error {
err = res.Iterate(func(r *chai.Row) error {
wantCount++
return nil
})

View File

@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/chaisql/chai/internal/encoding"
"github.com/cockroachdb/pebble"
"github.com/genjidb/genji/internal/encoding"
)
type DumpPebbleOptions struct {

View File

@@ -5,14 +5,14 @@ import (
"io"
"os"
"github.com/chaisql/chai"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
)
// Restore a database from a file created by genji dump.
// This function can be provided with an existing database (genji cli use case),
// Restore a database from a file created by chai dump.
// This function can be provided with an existing database (chai cli use case),
// otherwise new database is being created.
func Restore(ctx context.Context, db *genji.DB, dumpFile, dbPath string) error {
func Restore(ctx context.Context, db *chai.DB, dumpFile, dbPath string) error {
if dbPath == "" {
return errors.New("database path expected")
}

View File

@@ -1,13 +1,13 @@
package dbutil
import (
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/query/statement"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/query/statement"
"github.com/chaisql/chai/internal/sql/parser"
)
func QueryTables(tx *genji.Tx, tables []string, fn func(name, query string) error) error {
query := "SELECT name, sql FROM __genji_catalog WHERE type = 'table' AND name NOT LIKE '__genji_%'"
func QueryTables(tx *chai.Tx, tables []string, fn func(name, query string) error) error {
query := "SELECT name, sql FROM __chai_catalog WHERE type = 'table' AND name NOT LIKE '__chai_%'"
if len(tables) > 0 {
query += " AND name IN ?"
}
@@ -18,7 +18,7 @@ func QueryTables(tx *genji.Tx, tables []string, fn func(name, query string) erro
}
defer res.Close()
return res.Iterate(func(r *genji.Row) error {
return res.Iterate(func(r *chai.Row) error {
// Get table name.
var name, query string
if err := r.Scan(&name, &query); err != nil {
@@ -29,9 +29,9 @@ func QueryTables(tx *genji.Tx, tables []string, fn func(name, query string) erro
})
}
func ListIndexes(db *genji.DB, tableName string) ([]string, error) {
func ListIndexes(db *chai.DB, tableName string) ([]string, error) {
var listName []string
q := "SELECT sql FROM __genji_catalog WHERE type = 'index'"
q := "SELECT sql FROM __chai_catalog WHERE type = 'index'"
if tableName != "" {
q += " AND owner.table_name = ?"
}
@@ -41,7 +41,7 @@ func ListIndexes(db *genji.DB, tableName string) ([]string, error) {
}
defer res.Close()
err = res.Iterate(func(r *genji.Row) error {
err = res.Iterate(func(r *chai.Row) error {
var query string
err = r.Scan(&query)
if err != nil {

View File

@@ -5,9 +5,9 @@ import (
"fmt"
"strings"
"github.com/chaisql/chai/internal/expr/functions"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/expr/functions"
"github.com/genjidb/genji/internal/sql/scanner"
)
var ErrNotFound = errors.New("No documentation found")

View File

@@ -5,10 +5,10 @@ import (
"regexp"
"testing"
"github.com/genjidb/genji/cmd/genji/doc"
"github.com/genjidb/genji/internal/expr/functions"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai/cmd/chai/doc"
"github.com/chaisql/chai/internal/expr/functions"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)

View File

@@ -1,6 +1,6 @@
package doc
import "github.com/genjidb/genji/internal/sql/scanner"
import "github.com/chaisql/chai/internal/sql/scanner"
var tokenDocs map[scanner.Token]string

View File

@@ -1,4 +1,4 @@
module github.com/genjidb/genji/cmd/genji
module github.com/chaisql/chai/cmd/chai
go 1.21
@@ -9,7 +9,7 @@ require (
github.com/charmbracelet/lipgloss v0.9.1
github.com/cockroachdb/errors v1.11.1
github.com/cockroachdb/pebble v0.0.0-20231130180345-51fca96df08f
github.com/genjidb/genji v0.16.0
github.com/chaisql/chai v0.16.0
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
go.uber.org/multierr v1.11.0
@@ -63,4 +63,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/genjidb/genji v0.16.0 => ../../
replace github.com/chaisql/chai v0.16.0 => ../../

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"os"
"github.com/genjidb/genji/cmd/genji/commands"
"github.com/chaisql/chai/cmd/chai/commands"
)
func main() {

View File

@@ -11,11 +11,11 @@ import (
"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/genjidb/genji/cmd/genji/doc"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/object"
"github.com/chaisql/chai"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/chaisql/chai/cmd/chai/doc"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/object"
)
type command struct {
@@ -131,14 +131,14 @@ func runDocCmd(expr string, out io.Writer) error {
}
// runTablesCmd displays all tables.
func runTablesCmd(db *genji.DB, w io.Writer) error {
res, err := db.Query("SELECT name FROM __genji_catalog WHERE type = 'table' AND name NOT LIKE '__genji_%'")
func runTablesCmd(db *chai.DB, w io.Writer) error {
res, err := db.Query("SELECT name FROM __chai_catalog WHERE type = 'table' AND name NOT LIKE '__chai_%'")
if err != nil {
return err
}
defer res.Close()
return res.Iterate(func(r *genji.Row) error {
return res.Iterate(func(r *chai.Row) error {
var tableName string
err = r.Scan(&tableName)
if err != nil {
@@ -151,10 +151,10 @@ func runTablesCmd(db *genji.DB, w io.Writer) error {
// runIndexesCmd displays a list of indexes. If table is non-empty, it only
// displays that table's indexes. If not, it displays all indexes.
func runIndexesCmd(db *genji.DB, tableName string, w io.Writer) error {
func runIndexesCmd(db *chai.DB, tableName string, w io.Writer) error {
// ensure table exists
if tableName != "" {
_, err := db.QueryRow("SELECT 1 FROM __genji_catalog WHERE name = ? AND type = 'table' LIMIT 1", tableName)
_, err := db.QueryRow("SELECT 1 FROM __chai_catalog WHERE name = ? AND type = 'table' LIMIT 1", tableName)
if err != nil {
if errs.IsNotFoundError(err) {
return errors.Wrapf(err, "table %s does not exist", tableName)
@@ -180,7 +180,7 @@ func runIndexesCmd(db *genji.DB, tableName string, w io.Writer) error {
// runSaveCommand saves the currently opened database at the given path.
// If a path already exists, existing values in the target database will be overwritten.
func runSaveCmd(ctx context.Context, db *genji.DB, dbPath string) error {
func runSaveCmd(ctx context.Context, db *chai.DB, dbPath string) error {
// Open the new database
otherDB, err := dbutil.OpenDB(ctx, dbPath)
if err != nil {
@@ -199,7 +199,7 @@ func runSaveCmd(ctx context.Context, db *genji.DB, dbPath string) error {
return otherDB.Exec(dbDump.String())
}
func runImportCmd(db *genji.DB, fileType, path, table string) error {
func runImportCmd(db *chai.DB, fileType, path, table string) error {
if strings.ToLower(fileType) != "csv" {
return errors.New("TYPE should be csv")
}

View File

@@ -3,13 +3,12 @@ package shell
import (
"bytes"
"context"
"io/ioutil"
"os"
"testing"
"github.com/genjidb/genji"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/cmd/chai/dbutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)
@@ -33,7 +32,7 @@ func TestRunTablesCmd(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -65,7 +64,7 @@ func TestIndexesCmd(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -91,11 +90,11 @@ func TestIndexesCmd(t *testing.T) {
}
func TestSaveCommand(t *testing.T) {
dir, err := ioutil.TempDir("", "genji")
dir, err := os.MkdirTemp("", "chai")
assert.NoError(t, err)
defer os.RemoveAll(dir)
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -115,7 +114,7 @@ func TestSaveCommand(t *testing.T) {
err = runSaveCmd(context.Background(), db, dir)
assert.NoError(t, err)
db, err = genji.Open(dir)
db, err = chai.Open(dir)
assert.NoError(t, err)
defer db.Close()

View File

@@ -18,12 +18,12 @@ import (
"go.uber.org/multierr"
"golang.org/x/sync/errgroup"
"github.com/genjidb/genji"
"github.com/genjidb/genji/cmd/genji/dbutil"
"github.com/chaisql/chai"
"github.com/chaisql/chai/cmd/chai/dbutil"
)
const (
historyFilename = ".genji_history"
historyFilename = ".chai_history"
)
var (
@@ -33,9 +33,9 @@ var (
errExitSignal = errors.New("termination signal received")
)
// A Shell manages a command line shell program for manipulating a Genji database.
// A Shell manages a command line shell program for manipulating a Chai database.
type Shell struct {
db *genji.DB
db *chai.DB
opts *Options
showTime bool

View File

@@ -87,7 +87,7 @@ func newQueryInputModel(shell *Shell) queryInputModel {
ta.SetHeight(1)
ta.SetPromptFunc(7, func(lineIdx int) string {
if lineIdx == 0 {
return "genji> "
return "chai> "
}
return "... "

28
db.go
View File

@@ -1,7 +1,7 @@
/*
Package genji implements an embedded SQL database.
package chai implements an embedded SQL database.
*/
package genji
package chai
import (
"bufio"
@@ -11,18 +11,18 @@ import (
"database/sql/driver"
"io"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/database/catalogstore"
"github.com/chaisql/chai/internal/environment"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/query"
"github.com/chaisql/chai/internal/query/statement"
"github.com/chaisql/chai/internal/sql/parser"
"github.com/chaisql/chai/internal/stream"
"github.com/chaisql/chai/internal/stream/rows"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/database/catalogstore"
"github.com/genjidb/genji/internal/environment"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/query"
"github.com/genjidb/genji/internal/query/statement"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/genjidb/genji/internal/stream"
"github.com/genjidb/genji/internal/stream/rows"
"github.com/genjidb/genji/internal/types"
)
// DB represents a collection of tables.
@@ -31,7 +31,7 @@ type DB struct {
ctx context.Context
}
// Open creates a Genji database at the given path.
// Open creates a Chai database at the given path.
// If path is equal to ":memory:" it will open an in-memory database,
// otherwise it will create an on-disk database.
func Open(path string) (*DB, error) {

View File

@@ -1,23 +1,22 @@
package genji_test
package chai_test
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"testing"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
)
func ExampleTx() {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
if err != nil {
log.Fatal(err)
}
@@ -73,11 +72,11 @@ func ExampleTx() {
}
func TestOpen(t *testing.T) {
dir, err := ioutil.TempDir("", "genji")
dir, err := os.MkdirTemp("", "chai")
assert.NoError(t, err)
defer os.RemoveAll(dir)
db, err := genji.Open(filepath.Join(dir, "testdb"))
db, err := chai.Open(filepath.Join(dir, "testdb"))
assert.NoError(t, err)
err = db.Exec(`
@@ -96,19 +95,19 @@ func TestOpen(t *testing.T) {
assert.NoError(t, err)
// ensure tables are loaded properly
db, err = genji.Open(filepath.Join(dir, "testdb"))
db, err = chai.Open(filepath.Join(dir, "testdb"))
assert.NoError(t, err)
defer db.Close()
res1, err := db.Query("SELECT * FROM __genji_catalog")
res1, err := db.Query("SELECT * FROM __chai_catalog")
assert.NoError(t, err)
defer res1.Close()
var count int
want := []string{
`{"name":"__genji_catalog", "namespace":1, "sql":"CREATE TABLE __genji_catalog (name TEXT NOT NULL, type TEXT NOT NULL, namespace INTEGER, sql TEXT, rowid_sequence_name TEXT, owner (table_name TEXT NOT NULL, paths ARRAY), CONSTRAINT __genji_catalog_pk PRIMARY KEY (name))", "type":"table"}`,
`{"name":"__genji_sequence", "sql":"CREATE TABLE __genji_sequence (name TEXT NOT NULL, seq INTEGER, CONSTRAINT __genji_sequence_pk PRIMARY KEY (name))", "namespace":2, "type":"table"}`,
`{"name":"__genji_store_seq", "owner":{"table_name":"__genji_catalog"}, "sql":"CREATE SEQUENCE __genji_store_seq MAXVALUE 9223372036837998591 START WITH 10 CACHE 0", "type":"sequence"}`,
`{"name":"__chai_catalog", "namespace":1, "sql":"CREATE TABLE __chai_catalog (name TEXT NOT NULL, type TEXT NOT NULL, namespace INTEGER, sql TEXT, rowid_sequence_name TEXT, owner (table_name TEXT NOT NULL, paths ARRAY), CONSTRAINT __chai_catalog_pk PRIMARY KEY (name))", "type":"table"}`,
`{"name":"__chai_sequence", "sql":"CREATE TABLE __chai_sequence (name TEXT NOT NULL, seq INTEGER, CONSTRAINT __chai_sequence_pk PRIMARY KEY (name))", "namespace":2, "type":"table"}`,
`{"name":"__chai_store_seq", "owner":{"table_name":"__chai_catalog"}, "sql":"CREATE SEQUENCE __chai_store_seq MAXVALUE 9223372036837998591 START WITH 10 CACHE 0", "type":"sequence"}`,
`{"name":"seqD", "sql":"CREATE SEQUENCE seqD INCREMENT BY 10 MINVALUE 100 START WITH 500 CYCLE", "type":"sequence"}`,
`{"name":"tableA", "sql":"CREATE TABLE tableA (a INTEGER NOT NULL, b (c (d DOUBLE NOT NULL)), CONSTRAINT tableA_a_unique UNIQUE (a), CONSTRAINT tableA_pk PRIMARY KEY (b.c.d))", "namespace":10, "type":"table"}`,
`{"name":"tableA_a_idx", "owner":{"table_name":"tableA", "paths":["a"]}, "sql":"CREATE UNIQUE INDEX tableA_a_idx ON tableA (a)", "namespace":11, "type":"index"}`,
@@ -117,7 +116,7 @@ func TestOpen(t *testing.T) {
`{"name":"tableC_a_b_idx", "owner":{"table_name":"tableC"}, "sql":"CREATE INDEX tableC_a_b_idx ON tableC (a, b)", "namespace":14, "type":"index"}`,
`{"name":"tableC_seq", "owner":{"table_name":"tableC"}, "sql":"CREATE SEQUENCE tableC_seq CACHE 64", "type":"sequence"}`,
}
err = res1.Iterate(func(r *genji.Row) error {
err = res1.Iterate(func(r *chai.Row) error {
count++
if count > len(want) {
return fmt.Errorf("more than %d relations", len(want))
@@ -132,17 +131,17 @@ func TestOpen(t *testing.T) {
assert.NoError(t, err)
testutil.RequireJSONEq(t, d, `{"a": "1"}`)
d, err = db.QueryRow("SELECT * FROM __genji_sequence")
d, err = db.QueryRow("SELECT * FROM __chai_sequence")
assert.NoError(t, err)
testutil.RequireJSONEq(t, d, `{"name":"__genji_store_seq", "seq":14}`)
testutil.RequireJSONEq(t, d, `{"name":"__chai_store_seq", "seq":14}`)
d, err = db.QueryRow("SELECT * FROM __genji_sequence OFFSET 1")
d, err = db.QueryRow("SELECT * FROM __chai_sequence OFFSET 1")
assert.NoError(t, err)
testutil.RequireJSONEq(t, d, `{"name": "seqD", "seq": 500}`)
}
func TestQueryRow(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
require.NoError(t, err)
@@ -181,20 +180,20 @@ func TestQueryRow(t *testing.T) {
t.Run("Should return an error if no row", func(t *testing.T) {
r, err := db.QueryRow("SELECT * FROM test WHERE a > 100")
require.True(t, genji.IsNotFoundError(err))
require.True(t, chai.IsNotFoundError(err))
require.Nil(t, r)
tx, err := db.Begin(false)
assert.NoError(t, err)
defer tx.Rollback()
r, err = tx.QueryRow("SELECT * FROM test WHERE a > 100")
require.True(t, genji.IsNotFoundError(err))
require.True(t, chai.IsNotFoundError(err))
require.Nil(t, r)
})
}
func TestPrepareThreadSafe(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -215,7 +214,7 @@ func TestPrepareThreadSafe(t *testing.T) {
}
defer res.Close()
return res.Iterate(func(d *genji.Row) error {
return res.Iterate(func(d *chai.Row) error {
return nil
})
})
@@ -226,7 +225,7 @@ func TestPrepareThreadSafe(t *testing.T) {
}
func TestIterateDeepCopy(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -251,7 +250,7 @@ func TestIterateDeepCopy(t *testing.T) {
}
var items []*item
err = res.Iterate(func(r *genji.Row) error {
err = res.Iterate(func(r *chai.Row) error {
var i item
err := r.StructScan(&i)
assert.NoError(t, err)
@@ -269,7 +268,7 @@ func TestIterateDeepCopy(t *testing.T) {
func BenchmarkSelect(b *testing.B) {
for size := 1; size <= 10000; size *= 10 {
b.Run(fmt.Sprintf("%.05d", size), func(b *testing.B) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(b, err)
err = db.Exec("CREATE TABLE foo")
@@ -283,7 +282,7 @@ func BenchmarkSelect(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
res, _ := db.Query("SELECT * FROM foo")
res.Iterate(func(d *genji.Row) error { return nil })
res.Iterate(func(d *chai.Row) error { return nil })
}
})
}
@@ -292,7 +291,7 @@ func BenchmarkSelect(b *testing.B) {
func BenchmarkSelectWhere(b *testing.B) {
for size := 1; size <= 10000; size *= 10 {
b.Run(fmt.Sprintf("%.05d", size), func(b *testing.B) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(b, err)
err = db.Exec("CREATE TABLE foo")
@@ -306,7 +305,7 @@ func BenchmarkSelectWhere(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
res, _ := db.Query("SELECT b FROM foo WHERE a > 0")
res.Iterate(func(d *genji.Row) error { return nil })
res.Iterate(func(d *chai.Row) error { return nil })
}
})
}
@@ -315,7 +314,7 @@ func BenchmarkSelectWhere(b *testing.B) {
func BenchmarkPreparedSelectWhere(b *testing.B) {
for size := 1; size <= 10000; size *= 10 {
b.Run(fmt.Sprintf("%.05d", size), func(b *testing.B) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(b, err)
err = db.Exec("CREATE TABLE foo")
@@ -330,7 +329,7 @@ func BenchmarkPreparedSelectWhere(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
res, _ := p.Query()
res.Iterate(func(d *genji.Row) error { return nil })
res.Iterate(func(d *chai.Row) error { return nil })
}
})
}
@@ -339,7 +338,7 @@ func BenchmarkPreparedSelectWhere(b *testing.B) {
func BenchmarkSelectPk(b *testing.B) {
for size := 1; size <= 10000; size *= 10 {
b.Run(fmt.Sprintf("%.05d", size), func(b *testing.B) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(b, err)
err = db.Exec("CREATE TABLE foo(a INT PRIMARY KEY)")
@@ -353,7 +352,7 @@ func BenchmarkSelectPk(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
res, _ := db.Query("SELECT * FROM foo WHERE a = ?", size-1)
res.Iterate(func(d *genji.Row) error { return nil })
res.Iterate(func(d *chai.Row) error { return nil })
}
})
}

View File

@@ -9,15 +9,15 @@ import (
"sync"
"time"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
)
func init() {
sql.Register("genji", sqlDriver{})
sql.Register("chai", sqlDriver{})
}
var (
@@ -25,8 +25,8 @@ var (
_ driver.DriverContext = (*sqlDriver)(nil)
)
// sqlDriver is a driver.Driver that can open a new connection to a Genji database.
// It is the driver used to register Genji against the database/sql package.
// sqlDriver is a driver.Driver that can open a new connection to a Chai database.
// It is the driver used to register Chai against the database/sql package.
type sqlDriver struct{}
func (d sqlDriver) Open(name string) (driver.Conn, error) {
@@ -34,7 +34,7 @@ func (d sqlDriver) Open(name string) (driver.Conn, error) {
}
func (d sqlDriver) OpenConnector(name string) (driver.Connector, error) {
db, err := genji.Open(name)
db, err := chai.Open(name)
if err != nil {
return nil, err
}
@@ -56,7 +56,7 @@ var (
type connector struct {
driver driver.Driver
db *genji.DB
db *chai.DB
closeOnce sync.Once
}
@@ -77,11 +77,11 @@ func (c *connector) Close() error {
return err
}
// conn represents a connection to the Genji database.
// conn represents a connection to the Chai database.
// It implements the database/sql/driver.Conn interface.
type conn struct {
db *genji.DB
tx *genji.Tx
db *chai.DB
tx *chai.Tx
}
// Prepare returns a prepared statement, bound to this connection.
@@ -91,7 +91,7 @@ func (c *conn) Prepare(q string) (driver.Stmt, error) {
// PrepareContext returns a prepared statement, bound to this connection.
func (c *conn) PrepareContext(ctx context.Context, q string) (driver.Stmt, error) {
var s *genji.Statement
var s *chai.Statement
var err error
if c.tx != nil {
@@ -155,7 +155,7 @@ func (c *conn) Rollback() error {
// Stmt is a prepared statement. It is bound to a Conn and not
// used by multiple goroutines concurrently.
type stmt struct {
stmt *genji.Statement
stmt *chai.Statement
}
// NumInput returns the number of placeholder parameters.
@@ -256,7 +256,7 @@ func (s stmt) Close() error {
var errStop = errors.New("stop")
type recordStream struct {
res *genji.Result
res *chai.Result
cancelFn func()
c chan row
wg sync.WaitGroup
@@ -264,11 +264,11 @@ type recordStream struct {
}
type row struct {
r *genji.Row
r *chai.Row
err error
}
func newRecordStream(res *genji.Result) *recordStream {
func newRecordStream(res *chai.Result) *recordStream {
ctx, cancel := context.WithCancel(context.Background())
ds := recordStream{
@@ -293,7 +293,7 @@ func (rs *recordStream) iterate(ctx context.Context) {
case <-rs.c:
}
err := rs.res.Iterate(func(r *genji.Row) error {
err := rs.res.Iterate(func(r *chai.Row) error {
select {
case <-ctx.Done():
return errStop
@@ -429,7 +429,7 @@ type valueScanner struct {
}
func (v valueScanner) Scan(src any) error {
if r, ok := src.(*genji.Row); ok {
if r, ok := src.(*chai.Row); ok {
return r.StructScan(v.dest)
}

View File

@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)
@@ -19,7 +19,7 @@ type rowtest struct {
type foo struct{ Foo string }
func TestDriver(t *testing.T) {
db, err := sql.Open("genji", ":memory:")
db, err := sql.Open("chai", ":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -265,7 +265,7 @@ func TestDriver(t *testing.T) {
}
func TestDriverWithTimeValues(t *testing.T) {
db, err := sql.Open("genji", ":memory:")
db, err := sql.Open("chai", ":memory:")
assert.NoError(t, err)
defer db.Close()

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"log"
"github.com/genjidb/genji/driver"
"github.com/chaisql/chai/driver"
)
type User struct {
@@ -15,7 +15,7 @@ type User struct {
}
func Example() {
db, err := sql.Open("genji", ":memory:")
db, err := sql.Open("chai", ":memory:")
if err != nil {
log.Fatal(err)
}

View File

@@ -1,9 +1,9 @@
package genji
package chai
import (
"github.com/chaisql/chai/internal/database"
errs "github.com/chaisql/chai/internal/errors"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
errs "github.com/genjidb/genji/internal/errors"
)
// IsNotFoundError determines if the given error is a NotFoundError.

View File

@@ -1,9 +1,9 @@
package genji_test
package chai_test
import (
"fmt"
"github.com/genjidb/genji"
"github.com/chaisql/chai"
)
type User struct {
@@ -18,13 +18,13 @@ type User struct {
func Example() {
// Create a database instance, here we'll store everything in memory
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
if err != nil {
panic(err)
}
defer db.Close()
// Create a table. Genji tables are schemaless by default, you don't need to specify a schema.
// Create a table. Chai tables are schemaless by default, you don't need to specify a schema.
err = db.Exec("CREATE TABLE user (name text, ...)")
if err != nil {
panic(err)
@@ -63,7 +63,7 @@ func Example() {
defer stream.Close()
// Iterate over the results
err = stream.Iterate(func(r *genji.Row) error {
err = stream.Iterate(func(r *chai.Row) error {
var u User
err = r.StructScan(&u)

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/genjidb/genji
module github.com/chaisql/chai
go 1.21

View File

@@ -6,12 +6,12 @@ import (
"sort"
"strings"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/pkg/atomic"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/pkg/atomic"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
// System tables
@@ -43,7 +43,7 @@ const (
// Catalog manages all database objects such as tables, indexes and sequences.
// It stores all these objects in memory for fast access. Any modification
// is persisted into the __genji_catalog table.
// is persisted into the __chai_catalog table.
type Catalog struct {
Cache *catalogCache
CatalogTable *CatalogStore

View File

@@ -5,16 +5,16 @@ import (
"math"
"testing"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/database"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/database"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/stretchr/testify/require"
)
@@ -423,7 +423,7 @@ func TestTxDropIndex(t *testing.T) {
_, err = catalog.GetIndex(tx, "idxBar")
assert.NoError(t, err)
// cf: https://github.com/genjidb/genji/issues/360
// cf: https://github.com/chaisql/chai/issues/360
_, err = catalog.GetTable(tx, "test")
assert.NoError(t, err)
@@ -445,27 +445,27 @@ func TestTxDropIndex(t *testing.T) {
}
func TestReadOnlyTables(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
res, err := db.Query(`
CREATE TABLE foo (a int, b (c double unique));
CREATE INDEX idx_foo_a ON foo(a);
SELECT * FROM __genji_catalog
SELECT * FROM __chai_catalog
`)
assert.NoError(t, err)
defer res.Close()
var i int
err = res.Iterate(func(r *genji.Row) error {
err = res.Iterate(func(r *chai.Row) error {
switch i {
case 0:
testutil.RequireJSONEq(t, r, `{"name":"__genji_catalog", "namespace":1, "sql":"CREATE TABLE __genji_catalog (name TEXT NOT NULL, type TEXT NOT NULL, namespace INTEGER, sql TEXT, rowid_sequence_name TEXT, owner (table_name TEXT NOT NULL, paths ARRAY), CONSTRAINT __genji_catalog_pk PRIMARY KEY (name))", "type":"table"}`)
testutil.RequireJSONEq(t, r, `{"name":"__chai_catalog", "namespace":1, "sql":"CREATE TABLE __chai_catalog (name TEXT NOT NULL, type TEXT NOT NULL, namespace INTEGER, sql TEXT, rowid_sequence_name TEXT, owner (table_name TEXT NOT NULL, paths ARRAY), CONSTRAINT __chai_catalog_pk PRIMARY KEY (name))", "type":"table"}`)
case 1:
testutil.RequireJSONEq(t, r, `{"name":"__genji_sequence", "sql":"CREATE TABLE __genji_sequence (name TEXT NOT NULL, seq INTEGER, CONSTRAINT __genji_sequence_pk PRIMARY KEY (name))", "namespace":2, "type":"table"}`)
testutil.RequireJSONEq(t, r, `{"name":"__chai_sequence", "sql":"CREATE TABLE __chai_sequence (name TEXT NOT NULL, seq INTEGER, CONSTRAINT __chai_sequence_pk PRIMARY KEY (name))", "namespace":2, "type":"table"}`)
case 2:
testutil.RequireJSONEq(t, r, `{"name":"__genji_store_seq", "owner":{"table_name":"__genji_catalog"}, "sql":"CREATE SEQUENCE __genji_store_seq MAXVALUE 9223372036837998591 START WITH 10 CACHE 0", "type":"sequence"}`)
testutil.RequireJSONEq(t, r, `{"name":"__chai_store_seq", "owner":{"table_name":"__chai_catalog"}, "sql":"CREATE SEQUENCE __chai_store_seq MAXVALUE 9223372036837998591 START WITH 10 CACHE 0", "type":"sequence"}`)
case 3:
testutil.RequireJSONEq(t, r, `{"name":"foo", "rowid_sequence_name":"foo_seq", "sql":"CREATE TABLE foo (a INTEGER, b (c DOUBLE), CONSTRAINT \"foo_b.c_unique\" UNIQUE (b.c))", "namespace":10, "type":"table"}`)
case 4:
@@ -569,7 +569,7 @@ func TestCatalogCreateSequence(t *testing.T) {
}
func TestCatalogConcurrency(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer db.Close()
@@ -599,7 +599,7 @@ func TestCatalogConcurrency(t *testing.T) {
assert.NoError(t, err)
// get the table in rt1: should not see the changes made by wt2
row, err := rt1.QueryRow("SELECT COUNT(*) FROM __genji_catalog WHERE name LIKE '%test2%'")
row, err := rt1.QueryRow("SELECT COUNT(*) FROM __chai_catalog WHERE name LIKE '%test2%'")
assert.NoError(t, err)
var i int
err = row.Scan(&i)
@@ -607,7 +607,7 @@ func TestCatalogConcurrency(t *testing.T) {
require.Equal(t, 0, i)
// get the modified table in rt1: should not see the changes made by wt2
row, err = rt1.QueryRow("SELECT sql FROM __genji_catalog WHERE name = 'test'")
row, err = rt1.QueryRow("SELECT sql FROM __chai_catalog WHERE name = 'test'")
assert.NoError(t, err)
var s string
err = row.Scan(&s)
@@ -619,14 +619,14 @@ func TestCatalogConcurrency(t *testing.T) {
assert.NoError(t, err)
// get the table in rt1: should not see the changes made by wt2
row, err = rt1.QueryRow("SELECT COUNT(*) FROM __genji_catalog WHERE name LIKE '%test2%'")
row, err = rt1.QueryRow("SELECT COUNT(*) FROM __chai_catalog WHERE name LIKE '%test2%'")
assert.NoError(t, err)
err = row.Scan(&i)
assert.NoError(t, err)
require.Equal(t, 0, i)
// get the modified table in rt1: should not see the changes made by wt2
row, err = rt1.QueryRow("SELECT sql FROM __genji_catalog WHERE name = 'test'")
row, err = rt1.QueryRow("SELECT sql FROM __chai_catalog WHERE name = 'test'")
assert.NoError(t, err)
err = row.Scan(&s)
assert.NoError(t, err)

View File

@@ -3,12 +3,12 @@ package catalogstore
import (
"strings"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/query/statement"
"github.com/chaisql/chai/internal/sql/parser"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/query/statement"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
func LoadCatalog(tx *database.Transaction) error {
@@ -24,7 +24,7 @@ func LoadCatalog(tx *database.Transaction) error {
return errors.Wrap(err, "failed to load catalog store")
}
// add the __genji_catalog table to the list of tables
// add the __chai_catalog table to the list of tables
// so that it can be queried
ti := tx.Catalog.CatalogTable.Info().Clone()
// make sure that table is read-only

View File

@@ -4,11 +4,11 @@ import (
"fmt"
"strings"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/stringutil"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/stringutil"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
// FieldConstraint describes constraints on a particular field.

View File

@@ -4,12 +4,12 @@ import (
"fmt"
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -7,16 +7,16 @@ import (
"sync"
"sync/atomic"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/kv"
"github.com/chaisql/chai/internal/pkg/pebbleutil"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/vfs"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/kv"
"github.com/genjidb/genji/internal/pkg/pebbleutil"
)
const (
InternalPrefix = "__genji_"
InternalPrefix = "__chai_"
)
type Database struct {
@@ -127,7 +127,7 @@ func OpenPebble(path string, popts *pebble.Options) (*pebble.DB, error) {
return pebble.Open(path, popts)
}
// DefaultComparer is the default implementation of the Comparer interface for Genji.
// DefaultComparer is the default implementation of the Comparer interface for chai.
var DefaultComparer = &pebble.Comparer{
Compare: encoding.Compare,
Equal: encoding.Equal,

View File

@@ -4,13 +4,13 @@ import (
"testing"
"time"
"github.com/genjidb/genji"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai"
"github.com/chaisql/chai/internal/testutil/assert"
)
// See issue https://github.com/genjidb/genji/issues/298
// See issue https://github.com/chaisql/chai/issues/298
func TestConcurrentTransactionManagement(t *testing.T) {
db, err := genji.Open(":memory:")
db, err := chai.Open(":memory:")
assert.NoError(t, err)
defer func() {
assert.NoError(t, db.Close())

View File

@@ -4,10 +4,10 @@ import (
"encoding/binary"
"strings"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
)
// EncodeObject validates a row against all the constraints of the table

View File

@@ -3,11 +3,11 @@ package database_test
import (
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -4,10 +4,10 @@ import (
"bytes"
"fmt"
"github.com/chaisql/chai/internal/kv"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/kv"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
var (

View File

@@ -4,14 +4,14 @@ import (
"fmt"
"testing"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/kv"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/kv"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -6,11 +6,11 @@ import (
"strconv"
"strings"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/stringutil"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/stringutil"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
// TableInfo contains information about a table.

View File

@@ -4,7 +4,7 @@ import (
"math"
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/chaisql/chai/internal/database"
"github.com/stretchr/testify/require"
)

View File

@@ -3,9 +3,9 @@ package database
import (
"math"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
)
type Pivot []types.Value

View File

@@ -1,8 +1,8 @@
package database
import (
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
)
type Row interface {

View File

@@ -4,11 +4,11 @@ import (
"fmt"
"strings"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
var sequenceTableInfo = &TableInfo{

View File

@@ -3,13 +3,13 @@ package database_test
import (
"testing"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/database/catalogstore"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/database/catalogstore"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -3,12 +3,12 @@ package database
import (
"fmt"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/kv"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/kv"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
)
// A Table represents a collection of objects.

View File

@@ -4,17 +4,17 @@ import (
"fmt"
"testing"
"github.com/chaisql/chai/internal/database"
errs "github.com/chaisql/chai/internal/errors"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/query/statement"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/vfs"
"github.com/genjidb/genji/internal/database"
errs "github.com/genjidb/genji/internal/errors"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/query/statement"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -3,8 +3,8 @@ package database
import (
"sync"
"github.com/chaisql/chai/internal/kv"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/kv"
)
// Transaction represents a database transaction. It provides methods for managing the

View File

@@ -3,8 +3,8 @@ package encoding
import (
"encoding/binary"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
)
func EncodeArray(dst []byte, a types.Array) ([]byte, error) {

View File

@@ -5,9 +5,9 @@ import (
"fmt"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/chaisql/chai/internal/encoding"
"github.com/stretchr/testify/require"
)

View File

@@ -4,8 +4,8 @@ import (
"encoding/binary"
"fmt"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
)
func EncodeObject(dst []byte, d types.Object) ([]byte, error) {

View File

@@ -4,10 +4,10 @@ import (
"fmt"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"time"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/types"
)
func EncodeBoolean(dst []byte, x bool) []byte {

View File

@@ -5,10 +5,10 @@ import (
"math"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/tree"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/tree"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -281,7 +281,7 @@ func Successor(dst, a []byte) []byte {
// Equal function to determine if the original keys are equal.
// The key is constructed as follows:
// - 12 bits: the namespace, from 0 to 4096. If bigger than 4096, returns math.MaxUint64.
// - 4 bits: the Genji type of the first value.
// - 4 bits: the Chai type of the first value.
// - 48 bits: a representation of the first value of the key, depending on its type.
func AbbreviatedKey(key []byte) uint64 {
if len(key) == 0 {

View File

@@ -6,11 +6,11 @@ import (
"strings"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/tree"
"github.com/chaisql/chai/internal/encoding"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/tree"
"github.com/stretchr/testify/require"
)

View File

@@ -5,7 +5,7 @@ import (
"math"
"testing"
"github.com/genjidb/genji/internal/encoding"
"github.com/chaisql/chai/internal/encoding"
"github.com/stretchr/testify/require"
)

View File

@@ -3,9 +3,9 @@ package environment
import (
"fmt"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
)
// A Param represents a parameter passed by the user to the statement.

View File

@@ -1,9 +1,9 @@
package expr
import (
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/types"
)
// IsArithmeticOperator returns true if e is one of

View File

@@ -3,10 +3,10 @@ package expr
import (
"fmt"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/types"
)
// A cmpOp is a comparison operator.

View File

@@ -3,9 +3,9 @@ package expr_test
import (
"testing"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/types"
)
func TestComparisonExpr(t *testing.T) {

View File

@@ -1,10 +1,10 @@
package expr
import (
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/types"
)
type ConstraintExpr struct {

View File

@@ -3,8 +3,8 @@ package expr
import (
"fmt"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/types"
)
var (

View File

@@ -5,12 +5,12 @@ import (
"strings"
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/sql/parser"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -4,11 +4,11 @@ import (
"fmt"
"time"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
)
var builtinFunctions = Definitions{

View File

@@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"
"github.com/genjidb/genji/internal/testutil"
"github.com/chaisql/chai/internal/testutil"
)
func TestBuiltinFunctions(t *testing.T) {

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/genjidb/genji/internal/expr"
"github.com/chaisql/chai/internal/expr"
)
// variadicArity represents an unlimited number of arguments.

View File

@@ -3,10 +3,10 @@ package functions_test
import (
"testing"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/expr/functions"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/expr/functions"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/stretchr/testify/require"
)

View File

@@ -5,8 +5,8 @@ import (
"math"
"math/rand"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
)
// MathFunctions returns all math package functions.

View File

@@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"
"github.com/genjidb/genji/internal/testutil"
"github.com/chaisql/chai/internal/testutil"
)
func TestMathFunctions(t *testing.T) {

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/types"
)
// A ScalarDefinition is the definition type for functions which operates on scalar values in contrast to other SQL functions

View File

@@ -3,13 +3,13 @@ package functions_test
import (
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/expr/functions"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/expr/functions"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/types"
)
var stringsFunctions = Definitions{

View File

@@ -3,10 +3,10 @@ package expr
import (
"fmt"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr/glob"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr/glob"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/types"
)
func like(pattern, text string) bool {

View File

@@ -4,10 +4,10 @@ import (
"fmt"
"strings"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/stringutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/stringutil"
"github.com/chaisql/chai/internal/types"
)
// A LiteralValue represents a literal value of any type defined by the value package.

View File

@@ -3,9 +3,9 @@ package expr
import (
"fmt"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/types"
)
// AndOp is the And operator.

View File

@@ -3,11 +3,11 @@ package expr
import (
"fmt"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/sql/scanner"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/sql/scanner"
"github.com/genjidb/genji/internal/types"
)
type simpleOperator struct {

View File

@@ -3,8 +3,8 @@ package expr_test
import (
"testing"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/types"
)
func TestConcatExpr(t *testing.T) {

View File

@@ -3,8 +3,8 @@ package expr
import (
"fmt"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/types"
)
// NamedParam is an expression which represents the name of a parameter.

View File

@@ -1,10 +1,10 @@
package expr
import (
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/types"
"github.com/cockroachdb/errors"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/types"
)
// A Path is an expression that extracts a value from a object at a given path.

View File

@@ -5,14 +5,14 @@ import (
"fmt"
"testing"
"github.com/genjidb/genji/internal/database"
"github.com/genjidb/genji/internal/environment"
"github.com/genjidb/genji/internal/expr"
"github.com/genjidb/genji/internal/object"
"github.com/genjidb/genji/internal/sql/parser"
"github.com/genjidb/genji/internal/testutil"
"github.com/genjidb/genji/internal/testutil/assert"
"github.com/genjidb/genji/internal/types"
"github.com/chaisql/chai/internal/database"
"github.com/chaisql/chai/internal/environment"
"github.com/chaisql/chai/internal/expr"
"github.com/chaisql/chai/internal/object"
"github.com/chaisql/chai/internal/sql/parser"
"github.com/chaisql/chai/internal/testutil"
"github.com/chaisql/chai/internal/testutil/assert"
"github.com/chaisql/chai/internal/types"
"github.com/stretchr/testify/require"
)

View File

@@ -4,8 +4,8 @@ import (
"bytes"
"io"
"github.com/chaisql/chai/internal/encoding"
"github.com/cockroachdb/pebble"
"github.com/genjidb/genji/internal/encoding"
)
const (

Some files were not shown because too many files have changed in this diff Show More