All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
INSERT Operations:
- Single row inserts with column specifications
- Bulk inserts (multiple VALUES)
- INSERT without column names (implicit ordering)
- Bidirectional conversion: SQL INSERT ↔ MongoDB insertOne/insertMany
-
UPDATE Operations:
- UPDATE with SET clause (single/multiple columns)
- Conditional updates with WHERE clause
- Bulk updates without WHERE
- Bidirectional conversion: SQL UPDATE ↔ MongoDB updateMany with $set
-
DELETE Operations:
- Conditional DELETE with WHERE clause
- Bulk DELETE without conditions
- Bidirectional conversion: SQL DELETE ↔ MongoDB deleteMany
-
JOIN Operations:
- INNER JOIN support with MongoDB
$lookupaggregation - LEFT JOIN support with
$lookuppreserving unmatched documents - Multi-table joins with ON conditions
- Proper field aliasing with table prefixes (e.g., u.name, o.order_id)
- INNER JOIN support with MongoDB
-
CREATE Operations:
- CREATE TABLE with column definitions
- Schema validation with BSON type mapping (INT→int, VARCHAR→string, FLOAT→double, etc.)
- CREATE INDEX with single/multiple columns
- Index sort order support (ASC→1, DESC→-1)
- Bidirectional conversion support
-
DROP Operations:
- DROP TABLE → MongoDB collection drop
- DROP INDEX → MongoDB dropIndex
- Safety: Requires
allow_mutations=Trueflag
-
DISTINCT Queries:
- Single field:
SELECT DISTINCT field FROM table - Multiple fields with aggregation pipeline
- Proper deduplication using MongoDB distinct() or $group
- Single field:
-
HAVING Clause:
- Post-aggregation filtering
- Works with GROUP BY and aggregation functions
- Converted to
$matchstage after$groupin aggregation pipeline
-
Aggregation Functions:
- COUNT(*) and COUNT(field)
- SUM(field)
- AVG(field)
- MIN(field)
- MAX(field)
- Proper integration with GROUP BY/HAVING
-
BETWEEN Operator:
- Syntax:
field BETWEEN val1 AND val2 - Converts to:
{field: {$gte: val1, $lte: val2}} - Smart AND parsing to avoid splitting BETWEEN's internal AND
- Syntax:
-
LIKE Operator with Wildcards:
%wildcard →.*regex pattern_wildcard →.regex pattern- Case-insensitive matching with
$options: "i" - Example:
name LIKE 'John%'→{name: {$regex: "John.*", $options: "i"}}
-
IN and NOT IN Operators:
field IN (val1, val2, ...)→{field: {$in: [val1, val2, ...]}}field NOT IN (...)→{field: {$nin: [...]}}- Proper list parsing with quotes and commas
-
IS NULL and IS NOT NULL:
field IS NULL→{field: None}or{field: {$eq: None}}field IS NOT NULL→{field: {$ne: None}}
-
OR Operator:
condition1 OR condition2→{$or: [{...}, {...}]}- Nested OR conditions with proper precedence
- Works with complex conditions
-
NOT Operator:
NOT condition→{$not: {...}}- Handles NOT with IN, LIKE, and other operators
- Proper precedence with AND/OR
-
Enhanced WHERE Clause Parser:
- Regex-based condition detection for complex patterns
- Smart AND splitting that preserves BETWEEN clauses
- Recursive parsing for nested conditions
- Proper operator precedence handling
-
sqlparse Token Handling:
- Fixed Function object detection for INSERT and CREATE INDEX
- Improved JOIN parsing with enumeration-based approach
- Better handling of Identifier vs Function tokens
- Robust parenthesis and quote parsing
-
Aggregation Pipeline Builder:
- Dynamic pipeline construction based on query features
- Stages: $match, $group, $lookup, $project, $sort, $limit, $skip
- Proper stage ordering for optimal query execution
- Support for complex GROUP BY with multiple aggregations
-
Keyword Separation:
MUTATION_KEYWORDS: INSERT, UPDATE, DELETE, CREATE (allowed withallow_mutations=True)DANGEROUS_KEYWORDS: DROP, TRUNCATE, ALTER, EXEC (require explicit permission)- Better security model for write operations
-
MongoDB Operator Validation:
- Added update operators: $set, $inc, $unset, $push, $pull
- Aggregation operators: $match, $group, $lookup, $project, $sort, $limit
- converter.py: Enhanced routing logic for all operation types
- sql_to_mongo.py:
- Expanded from ~200 lines to 400+ lines
- Added 8+ new parsing functions
- Improved WHERE clause parsing with 200+ lines of new logic
- mongo_to_sql.py: Added reverse conversion functions for INSERT, UPDATE, DELETE
- validator.py: Separated mutation keywords from dangerous keywords
- Test Coverage: From 58.55% to 59.27%
- Test Count: From 70 tests to 103 tests (+33 new tests)
- Error Handling: Better error messages for unsupported operations
- Type Mapping: Comprehensive SQL→BSON type conversion
- Documentation: Extensive README updates with examples
- INSERT Parsing: Fixed sqlparse treating
table(cols)as Function object - JOIN Parsing: Fixed token iteration issues with while loop
- CREATE INDEX Parsing: Fixed Function object detection
- BETWEEN Clause: Fixed AND splitting within BETWEEN
- NOT IN Parsing: Fixed regex capturing NOT separately from IN
- Test Validator: Updated DELETE test expectation (write operation vs dangerous)
-
New Test Files:
test_new_operations.py: 33 tests for CRUD, JOIN, CREATE, DROP operations
-
Code Metrics:
- Total tests: 103 passing
- Code coverage: 59.27%
- New functions: 15+
- Enhanced functions: 10+
-
Performance:
- All conversions maintain O(n) complexity
- Aggregation pipeline generation is optimized
- No performance degradation from new features
None - all changes are backward compatible. Existing v2.0.0 code will work with v2.1.0.
-
exceptions.py: Comprehensive custom exception classes
ConverterError: Base exception for all converter errorsSQLParseError: SQL parsing errorsMongoParseError: MongoDB parsing errorsValidationError: Query validation failuresInvalidQueryError: Malformed queriesConversionError: Conversion failuresTypeConversionError: Type conversion issuesUnsupportedOperationError: Unsupported operations
-
logger.py: Production-grade logging system
- Configurable logging levels
- File and console logging support
- Structured log format
- Logger instance management
-
validator.py: Query validation and sanitization
- SQL injection prevention
- Query syntax validation
- Dangerous keyword detection
- MongoDB operator validation
- Query length limits
- Nesting depth limits
- String and identifier sanitization
-
benchmark.py: Performance benchmarking utilities
- Function execution timing
- Statistical analysis (mean, median, std dev)
- Batch query benchmarking
- Performance comparison tools
- Results export to dictionary
-
cli.py: Command-line interface
- Interactive mode
- Batch conversion from files
- Colorized output (with colorama)
- Validation before conversion
- Verbose logging option
- File-based log output
- Comprehensive pytest test suite:
test_sql_to_mongo.py: 40+ tests for SQL to MongoDB conversiontest_mongo_to_sql.py: 35+ tests for MongoDB to SQL conversiontest_validator.py: 30+ tests for validation and sanitizationtest_benchmark.py: 20+ tests for benchmarking utilitiesconftest.py: Pytest fixtures and test data- Test coverage for edge cases and error handling
- Black: Code formatting
- Flake8: Linting
- Pylint: Advanced linting
- isort: Import sorting
- MyPy: Type checking
- pytest-cov: Code coverage reporting
pyproject.toml: Modern Python project configuration.flake8: Flake8 configuration.pylintrc: Pylint configuration.coveragerc: Coverage configurationpytest.ini: Pytest configurationrequirements-dev.txt: Development dependencies
examples/basic_usage.py: Basic conversion examplesexamples/advanced_usage.py: Advanced features (validation, logging, benchmarking)- Comprehensive docstrings throughout codebase
- Package version: Bumped from 1.2.2 to 2.0.0
- setup.py: Updated with new features and CLI entry point
- init.py: Expanded exports to include all new modules
- Package classifiers: Updated to "Production/Stable" status
- Error handling throughout the codebase
- Code organization and modularity
- Documentation and examples
- Test coverage (from ~10% to comprehensive coverage)
- Type safety with better type hints
- Security with query validation and sanitization
- Minimum Python version: 3.7+
- New dependencies:
- Core:
sqlparse>=0.4.0 - CLI (optional):
click>=8.0.0,colorama>=0.4.6 - Dev (optional):
pytest,pytest-cov,black,flake8,mypy, etc.
- Core:
- Basic SQL to MongoDB conversion
- Basic MongoDB to SQL conversion
- Support for SELECT, WHERE, ORDER BY, LIMIT, GROUP BY
- Support for MongoDB operators: $gt, $gte, $lt, $lte, $eq, $ne, $in, $nin, $regex
- Docker containerization
- PyPI package
For more information, see the README.md file.