This guide covers development setup, testing, and contribution guidelines for jsonlogic2sql.
- Go 1.25 or later
- Make (optional, for using Makefile)
# Clone the repository
git clone https://github.com/h22rana/jsonlogic2sql.git
cd jsonlogic2sql
# Install dependencies
make deps
# Run tests
make test
# Build the REPL
make build
# Run linter
make lintjsonlogic2sql/
├── transpiler.go # Main public API
├── transpiler_test.go # Public API tests
├── operator.go # Custom operators registry and types
├── operator_test.go # Custom operators tests
├── schema.go # Schema/metadata validation
├── schema_test.go # Schema tests
├── errors.go # Public error types
├── internal/
│ ├── parser/ # Core parsing logic
│ │ ├── parser.go # Recursive descent parser
│ │ └── parser_test.go
│ ├── operators/ # Operator implementations
│ │ ├── config.go # Shared operator config
│ │ ├── constants.go # Operator name constants
│ │ ├── data.go # var, missing, missing_some
│ │ ├── comparison.go # ==, !=, >, <, in, etc.
│ │ ├── logical.go # and, or, !, !!, if
│ │ ├── numeric.go # +, -, *, /, %, max, min
│ │ ├── string.go # cat, substr
│ │ ├── array.go # map, filter, reduce, all, some, none, merge
│ │ └── schema.go # SchemaProvider interface
│ ├── dialect/ # SQL dialect definitions
│ │ └── dialect.go # Dialect constants and helpers
│ ├── errors/ # Internal error types
│ │ └── errors.go # Error constructors
│ └── validator/ # Pre-validation logic
├── cmd/repl/ # Interactive REPL
│ └── main.go
├── docs/ # Documentation
├── Makefile # Build automation
├── CLAUDE.md # AI assistant context
└── README.md # Project overview
| Command | Description |
|---|---|
make test |
Run all tests |
make build |
Build REPL binary |
make lint |
Run linter |
make lint/fix |
Run linter with auto-fix |
make run |
Run REPL |
make bench |
Run benchmarks |
make deps |
Install dependencies |
make help |
Show available commands |
The project includes comprehensive tests:
- 3,000+ test cases across all packages
- 168 REPL test cases for integration testing
- Full coverage for all operators and dialects
- Cross-dialect regression matrices for nested built-in/custom flows:
array_edge_matrix_test.goarray_schema_alias_regression_test.gocustom_operator_array_edge_matrix_test.gocomparison_logical_numeric_matrix_test.godata_access_matrix_test.go
# All tests
go test ./...
# With verbose output
go test -v ./...
# With coverage
go test -cover ./...
# Specific package
go test ./internal/operators/
# Run specific test
go test -run TestTranspile ./...| Category | Description |
|---|---|
| Unit Tests | Each operator and component thoroughly tested |
| Integration Tests | End-to-end tests with real JSON Logic examples |
| Error Cases | Validation and error handling tests |
| Edge Cases | Boundary conditions and special cases |
| Dialect Tests | All 5 dialects tested for compatibility |
-
Add dialect constant in
internal/dialect/dialect.go:const ( DialectUnspecified Dialect = iota DialectBigQuery DialectSpanner DialectPostgreSQL DialectDuckDB DialectClickHouse DialectNewDialect // New dialect )
-
Update
String()andIsValid()methods in dialect.go -
Check each operator - Review the Dialect Compatibility Matrix and implement dialect-specific SQL where needed:
switch config.GetDialect() { case dialect.DialectBigQuery: return "STRPOS(str, val) > 0", nil case dialect.DialectNewDialect: return "LOCATE(val, str) > 0", nil // Dialect-specific syntax default: return "", fmt.Errorf("operator not supported for dialect: %s", config.GetDialect()) }
-
Update documentation - Add the new dialect to dialects.md
-
Add tests for the new dialect in relevant
*_test.gofiles
-
Choose the appropriate file based on operator category:
data.go- Data access operatorscomparison.go- Comparison operatorslogical.go- Logical operatorsnumeric.go- Numeric operatorsstring.go- String operatorsarray.go- Array operators
-
Add operator constant in
constants.go:const ( OperatorNewOp = "newOp" )
-
Implement the operator following existing patterns
-
Register in parser - Add to operator dispatch in
parser.go -
Add tests - Create comprehensive test cases
-
Update documentation - Add to operators.md
- Follow standard Go conventions
- Run
make lint/fixbefore committing - Keep functions focused and testable
- Document exported functions and types
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linter
- Submit a pull request
- Use descriptive commit messages
- Group related changes in commits
- Reference issues when applicable
- REPL - Interactive testing tool
- API Reference - Full API documentation