Commit cc2d37f
* feat: add stdin/stdout pipeline support (closes #65)
Implement comprehensive stdin/stdout pipeline support for all CLI commands
(validate, format, analyze, parse) with Unix pipeline conventions and
cross-platform compatibility.
Features:
- Auto-detection: Commands automatically detect piped input
- Explicit stdin: Support "-" as stdin marker for all commands
- Input redirection: Full support for "< file.sql" syntax
- Broken pipe handling: Graceful handling of Unix EPIPE errors
- Security: 10MB input limit to prevent DoS attacks
- Cross-platform: Works on Unix/Linux/macOS and Windows PowerShell
Implementation:
- Created stdin_utils.go with pipeline utilities:
- IsStdinPipe(): Detects piped input using golang.org/x/term
- ReadFromStdin(): Reads from stdin with size limits
- GetInputSource(): Unified input detection (stdin/file/direct SQL)
- WriteOutput(): Handles stdout and file output with broken pipe detection
- DetectInputMode(): Determines input mode based on args and stdin state
- ValidateStdinInput(): Security validation for stdin content
- Updated all commands with stdin support:
- validate.go: Stdin validation with temp file approach
- format.go: Stdin formatting (blocks -i flag appropriately)
- analyze.go: Stdin analysis with direct content processing
- parse.go: Stdin parsing with direct content processing
- Dependencies:
- Added golang.org/x/term for stdin detection
- Testing:
- Unit tests: stdin_utils_test.go with comprehensive coverage
- Integration tests: pipeline_integration_test.go for real pipeline testing
- Manual testing: Validated echo, cat, and redirect operations
- Documentation:
- Updated README.md with comprehensive pipeline examples
- Unix/Linux/macOS and Windows PowerShell examples
- Git hooks integration examples
Usage Examples:
echo "SELECT * FROM users" | gosqlx validate
cat query.sql | gosqlx format
gosqlx validate -
gosqlx format < query.sql
cat query.sql | gosqlx format | gosqlx validate
Cross-platform:
# Unix/Linux/macOS
cat query.sql | gosqlx format | tee formatted.sql | gosqlx validate
# Windows PowerShell
Get-Content query.sql | gosqlx format | Set-Content formatted.sql
"SELECT * FROM users" | gosqlx validate
Security:
- 10MB stdin size limit (MaxStdinSize constant)
- Binary data detection (null byte check)
- Input validation before processing
- Temporary file cleanup in validate command
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: resolve CI failures for PR #97
Fixed 3 critical issues causing all CI builds/tests to fail:
1. Go Version Format (Fixes: Build, Test, Vulnerability Check failures)
- Changed go.mod from 'go 1.24.0' (three-part) to 'go 1.24' (two-part)
- Three-part format not supported by Go 1.19/1.20 toolchains in CI
- Error: 'invalid go version 1.24.0: must match format 1.23'
2. Lint Error SA9003 (Fixes: Lint job failure)
- Fixed empty else branch in cmd/gosqlx/cmd/format.go:169-173
- Removed unnecessary else block while preserving same behavior
- Staticcheck SA9003: empty branch warning resolved
3. Workflow Go Version Mismatch (Fixes: Security scan failures)
- Updated .github/workflows/security.yml to use Go 1.24
- Both GoSec and GovulnCheck jobs now use Go 1.24
- Matches project requirements for golang.org/x/term v0.37.0
All changes maintain backward compatibility and functionality.
Related: #65 (stdin/stdout pipeline feature)
* fix: update all CI workflows to use Go 1.24
Updated Go version across all GitHub Actions workflows to match go.mod requirements:
- .github/workflows/go.yml: Changed build matrix from [1.19, 1.20, 1.21] to [1.24]
- .github/workflows/test.yml: Changed test matrix from [1.19, 1.20, 1.21] to [1.24]
- .github/workflows/test.yml: Changed benchmark job from 1.21 to 1.24
- .github/workflows/lint.yml: Changed from 1.21 to 1.24
This fixes all remaining CI failures caused by incompatibility between:
- Project dependencies (golang.org/x/term v0.37.0) requiring Go 1.24
- Old workflow configurations using Go 1.19-1.21
Related: PR #97, Issue #65
* chore: run go mod tidy to sync dependencies
Running go mod tidy updates go.mod format to go 1.24.0 (three-part)
which is the standard format for Go 1.24+. This resolves build failures
caused by out-of-sync go.mod and go.sum files.
Note: Go 1.24 supports both two-part (1.24) and three-part (1.24.0)
formats, but go mod tidy standardizes on three-part format.
* fix: remove empty if block in validate.go (SA9003)
* fix: update staticcheck to latest version for Go 1.24 compatibility
* fix: use os.TempDir() for cross-platform test compatibility
- Replace hardcoded /tmp/ path with os.TempDir()
- Add path/filepath import for filepath.Join
- Fixes Windows test failure in TestWriteOutput
* feat: add support for multi-column USING clauses in JOINs (Issue #70)
Implements SQL-92 compliant multi-column USING support for JOIN operations.
Changes:
- Modified parser.go to parse comma-separated column lists in USING clause
- Added logic to store single columns as Identifier (backward compatibility)
- Added logic to store multiple columns as ListExpression
- Added comprehensive test coverage for multi-column USING
Tests Added:
- TestParser_MultiColumnUSING: Tests single and multi-column USING with various JOIN types
- TestParser_MultiColumnUSINGEdgeCases: Tests error handling for invalid syntax
- TestParser_MultiColumnUSINGWithComplexQueries: Tests integration with WHERE, ORDER BY, LIMIT
Examples:
- Single column: JOIN table2 USING (id)
- Multiple columns: JOIN table2 USING (id, name, category)
All existing tests pass with race detection enabled.
Maintains full backward compatibility with single-column USING.
Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini.local>
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4be7652 commit cc2d37f
2 files changed
Lines changed: 336 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
914 | 927 | | |
915 | | - | |
916 | | - | |
917 | 928 | | |
| 929 | + | |
918 | 930 | | |
919 | | - | |
| 931 | + | |
920 | 932 | | |
921 | 933 | | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
922 | 942 | | |
923 | 943 | | |
924 | 944 | | |
| |||
0 commit comments