summaryrefslogtreecommitdiffstats
path: root/lib/SqlFormatter.php
Commit message (Collapse)AuthorAgeFilesLines
* Uppercasing reserved words #86HEADmasterErik Andersson2019-03-131-0/+8
|
* Add Indent Level as an arg for format method of Sqlformatter #88Erik Andersson2019-03-131-2/+2
|
* Add support for named parameters (e.g. ":name"), treats them the same as ↵Jeremy Dorn2015-03-301-3/+3
| | | | variables (e.g. "@name"). Fixes #74
* Add proper formatting for square bracket quoted strings (SQL Server style).Jeremy2014-04-161-7/+8
| | | | For #63
* Fixed formattingJonathan Drake2014-04-161-1/+1
|
* Added brackets as token boundariesJonathan Drake2014-04-161-1/+1
|
* Added EXEC as a reserved wordJonathan Drake2014-04-161-2/+2
|
* cleaner solution to highlight binary dataDominik Liebler2014-01-221-1/+5
| | | | and added new test highlightBinaryData to test for this case
* Prevent warnings in highlightTokenDominik Liebler2014-01-211-1/+1
|
* Fix PHP notice for queries that start with a boundary character.v1.2.17Jeremy Dorn2014-01-121-2/+2
| | | | This was caused by a missing isset check. Fixes #57
* Fix formatting of negative numbers (fixes #49).v1.2.16Jeremy Dorn2013-11-271-17/+23
| | | | Improve phpunit code coverage.
* Bump minor version number.Jeremy Dorn2013-11-271-1/+1
|
* Merge branch 'master' of https://github.com/augusteiner/sql-formatter into ↵Jeremy Dorn2013-11-271-5/+5
|\ | | | | | | | | | | | | augusteiner-master Conflicts: lib/SqlFormatter.php
| * Corrected class name pass for closures.José Augusto de Araújo Nascimento2013-11-261-6/+6
| |
* | Optimized speed of initializing reserved words list.Michal Brašna2013-11-261-15/+4
|/
* Increase PhpUnit code coverage.Jeremy Dorn2013-09-181-6/+7
| | | | | | Fix undefined variable $clause_limit notice. A couple PSR fixes. Bump version number.
* Update pull #52 - // Checks if we are out of the limit clauseLairson Alencar2013-09-161-2/+2
|
* Update pull #52Lairson Alencar2013-09-161-0/+5
|
* #34 - Added formatting to SQL LIMITLairson Alencar2013-09-161-5/+17
| | | | The Formatting was added as suggested by leeoniya (issue #34).
* A few PSR code fixes.Jeremy Dorn2013-09-021-5/+7
|
* Add highlighting support for binary/hex numbers and user-defined variables.Jeremy Dorn2013-09-021-17/+67
| | | | | | Add ":" to the boundary list (fixes ":=" assignment operator). Standardize whitespace around "if" clauses in the php code. Now there is always a space after "if" and before "(". Fixes #50
* Made compress remove extra whitespace from reserved words. Fixes #51Jeremy Dorn2013-09-021-1/+5
| | | | | | | | | | | | | | ```sql LEFT OUTER JOIN ``` becomes ```sql LEFT OUTER JOIN ```
* Bump version numberJeremy Dorn2013-07-111-1/+1
|
* Formatting and naming changes in order to merge @adityagoyal pull request.Jeremy Dorn2013-07-111-237/+194
|
* Merge branch 'master' of https://github.com/adityagoyal/sql-formatter into ↵Jeremy Dorn2013-07-101-13/+72
|\ | | | | | | adityagoyal-master
| * removed remove_blank_line method as suggested and calling format method to ↵adityagoyal2013-07-061-11/+1
| | | | | | | | | | | | | | format after removing comments. removed remove_blank_line method as suggested and calling format method to format after removing comments.
| * highlight mysql functions.adityagoyal2013-07-051-2/+71
| | | | | | | | | | Added methods to highlight mysql functions.Removed now() ,count from reserved keyword.They are a part of mysql functions.
* | Merge branch 'master' of https://github.com/adityagoyal/sql-formatter into ↵Jeremy Dorn2013-07-011-7/+21
|\ \ | |/ | | | | adityagoyal-master
| * removed XOR as it was there in reserved newline.Added LEFT OUTER JOIN and ↵adityagoyal2013-06-301-2/+2
| | | | | | | | | | | | | | RIGHT OUTER JOIN in newline. removed XOR as it was there in reserved newline.Added LEFT OUTER JOIN and RIGHT OUTER JOIN in newline.
| * removed extra parenthesis and indented code by replacing tab with spaces.adityagoyal2013-06-301-16/+16
| | | | | | | | | | removed extra parenthesis and indented code by replacing tab with spaces.
| * added reserved keys for sql formatteradityagoyal2013-06-301-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | added many reserved keywords of mysql. ( SQL_SMALL_RESULT , GEMINI,GEMINI_SPIN_RETRIES,MASTER_LOG_POS,MASTER_PASSWORD,MASTER_PORT,MASTER_USER,MATCH ,MAX_CONNECTIONS_PER_HOUR,MAX_QUERIES_PER_HOUR,MAX_ROWS,MAX_UPDATES_PER_HOUR,MAX_USER_C ONNECTIONS,RAID0,RAID_CHUNKS,RAID_CHUNKSIZE,RAID_TYPE, 'SQL_AUTO_IS_NULL', 'SQL_BIG_RESULT', 'SQL_BIG_SELECTS', 'SQL_BIG_TABLES', 'SQL_BUFFER_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_LOG_BIN', 'SQL_LOG_OFF', 'SQL_LOG_UPDATE', 'SQL_LOW_PRIORITY_UPDATES', 'SQL_MAX_JOIN_SIZE', 'SQL_QUOTE_SHOW_CREATE', 'SQL_SAFE_UPDATES', 'SQL_SELECT_LIMIT', 'SQL_SLAVE_SKIP_COUNTER', 'SQL_SMALL_RESULT', 'SQL_W STRIPED,true,'XOR')
| * removed new line between queriesadityagoyal2013-06-291-1/+12
| | | | | | | | | | Added a method remove_blank_lines(String) that checks for blank new line and removes it.
* | Added missing mysql 'CHARACTER SET' keywordStéphane Klein2013-06-241-1/+1
|/
* Added new compress method. Fixes #41Jeremy Dorn2013-06-121-1/+43
| | | | | Added test cases for CLI mode and compress method. Bumped patch version.
* Changed license to MIT to simplify inclusion in other libraries.v1.2.9jdorn2013-04-261-2/+2
|
* Improving block comment formatting. Fixes #37Jeremy Dorn2013-03-311-1/+3
|
* Fixing bug with comment formatting. Fixes #36Jeremy Dorn2013-03-311-11/+11
|
* Improved formatting of inline parentheses. Fixes #32Jeremy Dorn2013-03-201-56/+82
| | | | | Added "IFNULL" as a reserved word. Changed "NOW" to "NOW()" in the reserved word list so it can be used within inline parentheses.
* Merge branch 'master' of https://github.com/jdorn/sql-formatterJeremy Dorn2013-03-141-24/+54
|\ | | | | | | | | Conflicts: lib/SqlFormatter.php
| * Splitting special reserved words into "top level reserved" and "newline ↵Jeremy Dorn2013-03-111-29/+59
| | | | | | | | | | | | | | reserved". Now, JOIN keywords and logical operators (AND, OR, etc.) have a new line before them. Fixes #30 Also adding the composer.lock file to VSC.
* | Adding support for CLI syntax highlighting. Fixes #33Jeremy Dorn2013-03-141-16/+87
|/
* Fixed formatting bug with multiple boundary characters (e.g. ">=", "<>", ↵Jeremy Dorn2013-03-071-13/+16
| | | | | | etc.). Fixes #29 Improved code coverage in unit tests. Now everything is covered except the infinite loop catching code which I don't know how to test.
* Fixing utf-8 encoding bug with PHP 5.3. Fixes #27Jeremy Dorn2013-03-071-1/+1
|
* replace 'static' keyword by 'self' to be compatible with php 5.2Franck Magnan2013-03-061-3/+3
|
* fixed formattingFranck Magnan2013-03-051-3/+3
|
* remove option from output method and use attribute insteadFranck Magnan2013-03-051-12/+13
|
* adding option to deactivate preformatted textFranck Magnan2013-03-051-4/+23
|
* Fixed bug when formatting "SELECT#comment" without a space before "#".Jeremy Dorn2013-03-031-2/+2
| | | | Added PHPUnit tests and .travis integration.
* Fixing bug with parsing long strings. PCRE was seg faulting. Fixes #25Jeremy Dorn2013-02-211-1/+1
|
* Using class constants for token types and token components now.Jeremy Dorn2013-02-101-61/+78
| | | | Resulted in a ~35% reduction in memory use and a slight decrease in performance.
* Improving splitQuery method. Fixes #22Jeremy Dorn2013-02-101-8/+12
|
* Making it easier to customize appearance.Jeremy Dorn2013-01-171-23/+24
| | | | | | Now, you can set whatever html attributes you want for each token type. Previously you could only set the value of the style attribute. You can also now set the html attributes for the containing pre tag. These changes make it easy to use classes instead of styles for example.
* Fixed bug with unterminated strings.Jeremy Dorn2013-01-081-27/+28
| | | | | Changed behavior when a parse error is encountered. It use to throw an exception, but now it just returns the remaining string as a single token. Split highlighting logic for backtick quote and other quotes to make the code cleaner.
* Fixed formatting bug when 2 special reserved words immediately followed each ↵Jeremy Dorn2012-12-291-2/+6
| | | | | | | | other. Added set operators to special reserved list (UNION, UNION ALL, EXCEPT, and INTERSECT). Updated test sql list to reduce the number of similar queries and better reflect real world usecases. Improved output of the regression test to make debugging easier.
* Removing "INSERT INTO" as a special reserved word. It looks better if ↵Jeremy Dorn2012-12-271-1/+1
| | | | formatted as a regular reserved word.
* Small bug fix and version bump.Jeremy Dorn2012-12-271-2/+2
|
* Fixing formatting bug when a special reserved word has multiple whitespace ↵Jeremy Dorn2012-12-271-3/+9
| | | | characters in the middle (e.g. "Group By").
* Fixed a couple formatting bugs. Added a few more optimizations.Jeremy Dorn2012-12-251-70/+96
| | | | | | | | | | | | Specifically: - Fixed double newlines that were appearing in some cases - Improved algorithm for inline parentheses. Now "decimal(7,2)" and "(table.column) will be inline - Fixed formatting bug with "ON UPDATE CURRENT_TIMESTAMP" - Fixed bug with numbers followed immediately by quotes (e.g. 1"test") - Reduced calls to highlightToken() - Used if blocks instead of switch statement when deciding how to highlight token - Used single quoted strings when possible to avoid parsing overhead
* Fixed lots of formatting bugs and inconsistencies. Rewrote the format ↵Jeremy Dorn2012-12-241-150/+199
| | | | method to better handle indentation.
* Major refactoring of code to improve performance. Now using primarily ↵Jeremy Dorn2012-12-231-143/+117
| | | | | | | regular expressions instead of loops. 2x performance increase. Found and fixed a minor bug in the process. "1.00" was being counted as 3 separate tokens ("1", ".", and "00") instead of a single number token. Added a simple regression testing script.
* Implemented caching during tokenization. Added a script for testing ↵v1.2.0Jeremy Dorn2012-12-221-7/+56
| | | | performance. Bumped the dev version number.
* Some code readability cleanup and additional micro-optimizationsJoseph Bielawski2012-12-191-81/+99
|
* Another optimization. Was performing an array merge for every format, ↵Jeremy Dorn2012-12-181-9/+14
| | | | changed it to only do it once.
* Update lib/SqlFormatter.phpJoseph Bielawski2012-12-181-16/+14
| | | Introduce some micro-optimizations
* Fixing several bugs.Jeremy Dorn2012-11-121-2/+6
| | | | | | An exception was being thrown when the last line of a query was a comment (without trailing \n). A PHP notice was being thrown when the last character in a query was a '('. A PHP notice was being thrown when the last part of a query was a '(' followed by a string or punctuation and missing the closing ')'.
* Version bump.v1.1.0Jeremy Dorn2012-11-111-2/+3
|
* Fixed bug that was marking "from" a reserved word in "select mytable.from"Jeremy Dorn2012-11-021-16/+23
|
* Adding more punctuation to the word boundary list.Jeremy Dorn2012-10-311-1/+1
|
* Fixing bug that was adding a space between a function name and the opening ↵Jeremy Dorn2012-10-311-4/+9
| | | | | | parentheses. Now, it will only add a space if there was whitespace there originally. Adding "NOW" as a reserved word.
* Small code style changes from pull request.Jeremy Dorn2012-10-121-3/+2
|
* UNIX mode restored (Fffuuuu).Mathieu Chabanon2012-10-121-2/+8
|
* Restructuring code to make it more maintainable.v1.0.1Jeremy Dorn2012-10-041-194/+298
| | | | | Adding parameter to SqlFormatter::format() to disable syntax highlighting. Making the code compatible with PHP 5.2 by getting rid of an anonymous function.
* Formatted source code according to PSR-1 and PSR-2. Added composer supportFlorin Patan2012-09-101-0/+509