feat(jsqlparser): 首次提交

This commit is contained in:
2026-01-21 20:50:35 +08:00
commit dc8ea30850
461 changed files with 61538 additions and 0 deletions

35
src/site/site.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
JSQLParser library
%%
Copyright (C) 2004 - 2019 JSQLParser
%%
Dual licensed under GNU LGPL 2.1 or Apache License 2.0
#L%
-->
<project name="Maven" xmlns="http://maven.apache.org/DECORATION/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.7</version>
</skin>
<bannerLeft>
<name>JSqlParser</name>
</bannerLeft>
<body>
<links inherit="top">
<item name="JSqlParser" href="https://github.com/JSQLParser/JSqlParser"/>
</links>
<menu ref="parent" inherit="bottom"/>
<menu ref="modules" inherit="bottom"/>
<menu ref="reports" inherit="bottom"/>
</body>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="129.79562"
height="122.15379"
viewBox="0 0 129.79562 122.15379"
id="svg117"
sodipodi:docname="logo-no-background.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs121" />
<sodipodi:namedview
id="namedview119"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false" />
<g
id="g92"
transform="matrix(1.2979533,0,0,1.2979533,4.7493164e-4,-3.8203598)">
<svg
viewBox="0 0 104.43066 98.282562"
height="98.282562"
width="104.43066"
version="1.1"
id="svg90">
<g
id="g88">
<svg
version="1.1"
x="0"
y="0"
viewBox="-1.2636185e-05 2.9436085 100.00003 94.112778"
xml:space="preserve"
width="104.43066"
height="98.282562"
class="icon-icon-0"
data-fill-palette-color="accent"
id="icon-0"><g
fill="#d90000"
data-fill-palette-color="accent"
id="g85"><path
d="m 82.643,61.574 c -0.346,0 -0.692,-0.104 -0.991,-0.316 C 80.992,60.79 80.75,59.92 81.075,59.177 83.303,54.082 79.745,51.302 68.159,44.03 58.741,38.111 57.22,32.04 57.606,27.991 c 0.623,-6.572 6.779,-12.603 16.886,-16.548 0.886,-0.345 1.875,0.093 2.217,0.972 0.344,0.88 -0.09,1.873 -0.971,2.215 -8.862,3.458 -14.228,8.445 -14.725,13.684 -0.42,4.435 2.68,8.868 8.966,12.818 7.997,5.02 13.974,8.77 15.014,13.759 2.886,-3.537 4.388,-6.999 4.476,-10.334 0.094,-3.633 -1.521,-7.198 -4.804,-10.597 -1.114,-1.146 -2.201,-2.218 -3.237,-3.239 -2.633,-2.598 -4.908,-4.842 -6.578,-7.239 -0.538,-0.775 -0.348,-1.842 0.426,-2.381 0.78,-0.543 1.841,-0.348 2.384,0.426 1.487,2.138 3.659,4.279 6.171,6.758 1.051,1.037 2.157,2.127 3.292,3.294 3.947,4.087 5.887,8.482 5.767,13.067 -0.143,5.451 -3.199,10.992 -9.082,16.468 -0.326,0.305 -0.745,0.46 -1.165,0.46 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path31" /><path
d="m 74.942,17.828 c -0.886,0 -1.635,-0.683 -1.703,-1.58 -0.202,-2.638 0.307,-4.913 1.556,-6.956 0.45,-0.732 1.375,-1.014 2.153,-0.67 3.179,1.412 4.938,3.567 5.229,6.407 0.096,0.94 -0.588,1.78 -1.527,1.878 -0.925,0.099 -1.778,-0.587 -1.876,-1.528 -0.081,-0.773 -0.367,-1.828 -1.759,-2.818 -0.346,1.026 -0.464,2.145 -0.365,3.425 0.073,0.942 -0.633,1.764 -1.574,1.836 -0.045,0.004 -0.091,0.006 -0.134,0.006 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path33" /><path
d="m 84.922,33.456 c -0.367,0 -0.739,-0.119 -1.051,-0.362 -0.745,-0.582 -0.876,-1.657 -0.295,-2.402 2.163,-2.772 5.211,-3.991 9.048,-3.627 1.474,-0.057 2.525,-0.417 3.127,-1.07 0.546,-0.592 0.823,-1.536 0.829,-2.808 -6.028,-6.561 -11.872,-9.717 -17.362,-9.355 -0.951,0.044 -1.757,-0.655 -1.818,-1.598 -0.061,-0.943 0.654,-1.757 1.598,-1.817 6.728,-0.446 13.634,3.251 20.547,10.944 0.259,0.29 0.413,0.66 0.434,1.049 0.141,2.53 -0.434,4.515 -1.709,5.901 -1.263,1.375 -3.167,2.108 -5.655,2.178 -0.079,-0.004 -0.149,-0.001 -0.222,-0.009 -2.727,-0.284 -4.667,0.456 -6.121,2.318 -0.336,0.432 -0.841,0.658 -1.35,0.658 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path35" /><path
d="m 88.573,37.734 c -0.859,0 -1.599,-0.644 -1.698,-1.518 -0.108,-0.938 0.566,-1.786 1.505,-1.893 3.61,-0.412 5.034,-2.134 4.763,-5.758 -0.071,-0.942 0.635,-1.764 1.578,-1.835 0.929,-0.059 1.763,0.636 1.833,1.579 0.409,5.451 -2.356,8.794 -7.785,9.413 -0.067,0.008 -0.131,0.012 -0.196,0.012 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path37" /><path
d="m 59.832,57.069 c -0.505,0 -1.006,-0.222 -1.344,-0.649 -0.586,-0.741 -0.462,-1.818 0.279,-2.405 0.741,-0.586 1.116,-1.214 1.15,-1.922 0.045,-0.977 -0.584,-2.163 -1.728,-3.255 -1.047,-1.047 -2.214,-1.677 -3.601,-1.955 -0.544,-0.109 -1.002,-0.476 -1.228,-0.984 -0.226,-0.508 -0.191,-1.093 0.094,-1.571 2.026,-3.389 2.639,-6.237 1.821,-8.461 C 54.41,33.509 51.86,31.592 47.699,30.17 31.227,24.558 20.218,17.313 14.897,8.595 c -0.955,3.632 0.228,8.349 9.25,13.754 0.812,0.485 1.075,1.537 0.59,2.347 -0.483,0.811 -1.535,1.078 -2.346,0.588 C 9.055,17.299 10.087,9.182 13.301,3.778 c 0.326,-0.551 0.916,-0.86 1.58,-0.833 0.641,0.041 1.204,0.438 1.46,1.028 4.006,9.261 14.929,16.985 32.462,22.958 5.189,1.773 8.447,4.383 9.685,7.758 1.014,2.763 0.652,5.956 -1.077,9.514 1.169,0.514 2.23,1.246 3.172,2.188 1.859,1.776 2.845,3.869 2.752,5.864 -0.081,1.704 -0.925,3.242 -2.442,4.444 -0.314,0.248 -0.69,0.37 -1.061,0.37 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path39" /><path
d="m 22.129,32.316 c -0.171,0 -0.346,-0.027 -0.518,-0.082 -5.722,-1.822 -9.487,-4.666 -11.192,-8.449 -1.664,-3.693 -1.34,-8.213 0.962,-13.435 0.383,-0.866 1.397,-1.253 2.256,-0.874 0.865,0.381 1.258,1.391 0.876,2.255 -1.896,4.295 -2.222,7.877 -0.974,10.647 1.289,2.861 4.354,5.08 9.109,6.596 0.902,0.287 1.399,1.249 1.112,2.15 -0.232,0.727 -0.906,1.192 -1.631,1.192 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path41" /><path
d="m 29.58,41.912 c -6.639,0 -14.305,-3.115 -17.717,-15.944 -0.242,-0.914 0.301,-1.851 1.214,-2.094 0.91,-0.249 1.849,0.301 2.095,1.214 2.623,9.871 8.036,14.202 16.525,13.283 0.933,-0.091 1.786,0.575 1.888,1.514 0.102,0.939 -0.576,1.784 -1.515,1.888 -0.806,0.088 -1.639,0.139 -2.49,0.139 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path43" /><path
d="m 36.542,48.407 c -6.582,0 -11.463,-2.843 -14.544,-8.484 -0.454,-0.829 -0.147,-1.87 0.682,-2.323 0.825,-0.451 1.869,-0.147 2.32,0.682 2.996,5.484 8.007,7.574 15.334,6.375 0.922,-0.146 1.812,0.48 1.963,1.414 0.153,0.932 -0.479,1.812 -1.413,1.963 -1.52,0.249 -2.969,0.373 -4.342,0.373 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path45" /><path
d="m 44.087,54.85 c -6.522,0 -11.029,-2.674 -13.422,-7.971 -0.389,-0.862 -0.006,-1.875 0.857,-2.264 0.863,-0.39 1.875,-0.004 2.263,0.855 2.079,4.61 6.06,6.457 12.534,5.845 0.925,-0.098 1.776,0.599 1.867,1.541 0.091,0.942 -0.599,1.776 -1.54,1.866 -0.885,0.085 -1.737,0.128 -2.559,0.128 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path47" /><path
d="m 54.24,68.361 c -0.196,0 -0.397,-0.033 -0.592,-0.106 C 41.475,63.767 35.987,58.309 37.34,52.033 c 0.198,-0.925 1.104,-1.519 2.031,-1.313 0.924,0.198 1.513,1.108 1.313,2.032 -1.165,5.419 7.05,9.675 14.147,12.292 0.886,0.326 1.34,1.311 1.014,2.197 -0.255,0.692 -0.909,1.12 -1.605,1.12 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path49" /><path
d="m 56.694,47.487 c -0.637,0 -1.246,-0.355 -1.542,-0.965 -0.411,-0.851 -0.057,-1.874 0.793,-2.286 3.252,-1.577 4.993,-3.713 5.321,-6.53 0.11,-0.939 0.984,-1.603 1.899,-1.501 0.939,0.109 1.611,0.959 1.501,1.898 -0.468,4.014 -2.9,7.113 -7.227,9.212 -0.24,0.117 -0.495,0.172 -0.745,0.172 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path51" /><path
d="m 63.994,91.289 c -0.149,0 -0.303,-0.02 -0.456,-0.062 -0.91,-0.25 -1.444,-1.193 -1.193,-2.105 1.564,-5.671 2.562,-11.09 2.965,-16.108 0.041,-0.521 0.32,-0.994 0.755,-1.285 5.347,-3.58 7.435,-9.121 6.384,-16.942 -0.126,-0.937 0.531,-1.798 1.468,-1.923 0.916,-0.126 1.798,0.531 1.923,1.467 1.181,8.785 -1.238,15.428 -7.187,19.763 -0.46,5.005 -1.47,10.361 -3.011,15.94 -0.208,0.758 -0.898,1.255 -1.648,1.255 z m -5.706,-2.908 c -0.865,0 -1.607,-0.652 -1.7,-1.532 -0.898,-8.506 -0.083,-12.703 0.705,-16.761 0.181,-0.927 1.081,-1.537 2.007,-1.354 0.927,0.181 1.535,1.079 1.353,2.006 -0.741,3.812 -1.507,7.752 -0.662,15.751 0.098,0.939 -0.582,1.782 -1.523,1.88 -0.06,0.006 -0.121,0.01 -0.18,0.01 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path53" /><path
d="m 67.014,74.863 c -0.776,0 -1.48,-0.532 -1.664,-1.323 -0.214,-0.922 0.358,-1.841 1.277,-2.055 8.207,-1.914 12.375,-3.82 13.933,-6.372 0.79,-1.293 0.924,-2.829 0.422,-4.836 -0.228,-0.916 0.328,-1.845 1.246,-2.075 0.924,-0.23 1.845,0.328 2.075,1.246 0.729,2.914 0.46,5.35 -0.823,7.449 -2.108,3.454 -6.767,5.749 -16.075,7.921 -0.132,0.031 -0.262,0.045 -0.391,0.045 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path55" /><path
d="m 22.188,91.289 c -0.562,0 -1.112,-0.277 -1.44,-0.784 -2.888,-4.474 -3.672,-7.903 -2.393,-10.478 1.13,-2.277 3.777,-3.592 7.865,-3.903 5.757,-1.094 9.337,-5.84 10.762,-14.485 0.153,-0.933 1.047,-1.564 1.965,-1.411 0.933,0.153 1.564,1.034 1.411,1.965 -1.662,10.096 -6.268,15.922 -13.692,17.319 -2.112,0.171 -4.553,0.639 -5.246,2.035 -0.668,1.346 0.116,3.867 2.205,7.103 0.511,0.794 0.283,1.853 -0.511,2.366 -0.287,0.185 -0.607,0.273 -0.926,0.273 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path57" /><path
d="m 55.92,77.433 c -3.024,0 -6.015,-1.313 -8.925,-3.918 -2.906,-2.802 -6.166,-4.081 -9.771,-3.902 -0.935,0.065 -1.751,-0.67 -1.802,-1.614 -0.053,-0.943 0.67,-1.751 1.613,-1.801 4.58,-0.265 8.716,1.364 12.289,4.81 2.859,2.56 5.627,3.476 8.429,2.766 0.914,-0.232 1.847,0.32 2.081,1.236 0.234,0.916 -0.32,1.847 -1.236,2.081 -0.894,0.228 -1.788,0.342 -2.678,0.342 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path59" /><path
d="m 16.256,89.863 c -0.525,0 -1.041,-0.24 -1.375,-0.692 -3.824,-5.156 -4.93,-8.811 -3.944,-13.043 0.116,-0.499 0.452,-0.922 0.914,-1.147 4.289,-2.1 5.861,-4.757 4.94,-8.477 C 9.079,69.392 4.365,69.522 2.019,66.925 -0.423,64.215 0.359,59.299 4.477,51.463 5.068,48.478 4.149,46.95 2.26,45.207 -1.126,42.154 -0.693,37.085 3.459,31.315 3.87,30.744 4.581,30.482 5.271,30.656 c 0.682,0.174 1.187,0.747 1.275,1.444 0.487,3.851 1.945,4.97 3.79,6.387 l 0.529,0.409 c 1.603,1.207 2.474,2.86 2.497,4.761 0.035,3.013 -2.061,6.379 -5.912,9.503 -4.506,8.61 -3.354,10.956 -2.889,11.471 0.483,0.542 2.835,1.996 12.65,-1.962 0.422,-0.173 0.892,-0.165 1.313,0.011 0.419,0.179 0.749,0.517 0.917,0.94 1.69,4.228 2.085,10.033 -5.319,14.039 -0.383,2.44 0.208,5.028 3.506,9.473 0.564,0.758 0.405,1.831 -0.354,2.393 -0.306,0.228 -0.664,0.338 -1.018,0.338 z M 4.257,36.654 C 3.282,38.802 2.878,41.155 4.567,42.68 6.068,44.065 7.428,45.666 7.9,47.977 9.213,46.419 9.953,44.905 9.939,43.696 9.929,42.861 9.562,42.198 8.78,41.61 L 8.253,41.203 C 6.844,40.121 5.308,38.941 4.257,36.654 Z"
fill="#d90000"
data-fill-palette-color="accent"
id="path61" /><path
d="m 17.85,65.966 c -0.798,0 -1.513,-0.562 -1.676,-1.374 -1.087,-5.411 -0.393,-9.752 2.065,-12.901 2.749,-3.521 7.677,-5.473 14.646,-5.8 0.965,-0.025 1.745,0.686 1.79,1.63 0.043,0.943 -0.686,1.745 -1.629,1.788 -5.928,0.277 -10.001,1.788 -12.109,4.488 -1.818,2.326 -2.289,5.732 -1.407,10.119 0.187,0.927 -0.415,1.829 -1.34,2.016 -0.114,0.022 -0.228,0.034 -0.34,0.034 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path63" /><path
d="m 37.53,91.289 c -0.562,0 -1.112,-0.277 -1.44,-0.784 -2.886,-4.47 -3.667,-7.895 -2.389,-10.469 1.126,-2.266 3.753,-3.578 7.812,-3.904 2.523,-0.513 4.559,-1.643 6.221,-3.452 0.641,-0.698 1.723,-0.741 2.417,-0.102 0.696,0.639 0.743,1.721 0.102,2.416 -2.163,2.356 -4.914,3.873 -8.174,4.514 -0.067,0.014 -0.134,0.024 -0.2,0.027 -1.947,0.147 -4.415,0.619 -5.113,2.024 -0.666,1.342 0.114,3.861 2.201,7.092 0.511,0.794 0.283,1.853 -0.511,2.365 -0.287,0.185 -0.607,0.273 -0.926,0.273 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path65" /><path
d="m 31.596,89.863 c -0.458,0 -0.916,-0.185 -1.253,-0.546 -3.523,-3.79 -4.333,-8.479 -4.392,-11.743 -0.016,-0.945 0.737,-1.725 1.68,-1.743 0.012,0 0.022,0 0.032,0 0.931,0 1.694,0.747 1.711,1.68 0.047,2.668 0.688,6.478 3.476,9.475 0.643,0.692 0.603,1.774 -0.088,2.419 -0.331,0.307 -0.749,0.458 -1.166,0.458 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path67" /><path
d="m 77.681,91.289 c -0.149,0 -0.303,-0.02 -0.456,-0.062 -0.91,-0.252 -1.444,-1.193 -1.192,-2.105 1.711,-6.197 2.928,-17.969 3.252,-21.981 0.077,-0.943 0.906,-1.649 1.843,-1.568 0.941,0.077 1.645,0.902 1.568,1.843 -0.332,4.103 -1.582,16.163 -3.366,22.618 -0.208,0.758 -0.898,1.255 -1.649,1.255 z m -5.478,-2.908 c -0.851,0 -1.588,-0.633 -1.696,-1.499 -0.643,-5.148 -0.703,-10.206 -0.169,-14.24 0.124,-0.937 0.979,-1.584 1.92,-1.471 0.937,0.124 1.595,0.982 1.472,1.919 -0.495,3.755 -0.434,8.502 0.173,13.368 0.118,0.937 -0.548,1.794 -1.486,1.91 -0.072,0.009 -0.143,0.013 -0.214,0.013 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path69" /><path
d="m 86.123,20.282 c -0.387,0 -0.774,-0.131 -1.095,-0.397 L 84,19.029 c -0.727,-0.604 -0.825,-1.683 -0.22,-2.409 0.605,-0.729 1.684,-0.822 2.409,-0.22 l 1.028,0.856 c 0.727,0.604 0.825,1.683 0.22,2.409 -0.338,0.406 -0.825,0.617 -1.314,0.617 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path71" /><path
d="m 82.641,61.574 c -0.308,0 -0.621,-0.084 -0.902,-0.259 -0.804,-0.499 -1.047,-1.554 -0.548,-2.356 2.613,-4.197 3.509,-8.101 2.66,-11.602 -1.004,-4.14 -4.488,-8.016 -10.355,-11.52 -0.812,-0.484 -1.077,-1.535 -0.593,-2.346 0.485,-0.812 1.539,-1.076 2.346,-0.592 6.689,3.992 10.701,8.586 11.929,13.652 1.073,4.426 0.035,9.21 -3.083,14.216 -0.324,0.52 -0.882,0.807 -1.454,0.807 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path73" /><path
d="m 69.24,31.745 c -0.383,0 -0.77,-0.129 -1.089,-0.391 -3.427,-2.826 -6.296,-7.97 -0.493,-16.433 0.534,-0.778 1.599,-0.981 2.378,-0.443 0.78,0.534 0.979,1.599 0.444,2.379 -4.704,6.861 -2.34,10.052 -0.151,11.856 0.729,0.601 0.833,1.68 0.231,2.409 -0.338,0.411 -0.827,0.623 -1.32,0.623 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path75" /><path
d="m 78.29,97.056 c -1.063,0 -2.197,-0.051 -3.35,-0.104 -0.839,-0.037 -1.611,-0.073 -2.22,-0.072 -0.664,0 -1.273,-0.293 -1.717,-0.824 -1.79,-2.146 -0.495,-9.618 -0.482,-9.693 0.171,-0.927 1.059,-1.533 1.991,-1.377 0.929,0.169 1.546,1.059 1.377,1.99 -0.346,1.9 -0.515,5.13 -0.31,6.496 0.466,0.014 0.979,0.037 1.516,0.063 1.354,0.061 3.843,0.171 5.253,0.002 -0.534,-0.509 -1.537,-1.32 -3.415,-2.517 -0.796,-0.507 -1.032,-1.564 -0.523,-2.362 0.509,-0.794 1.564,-1.034 2.362,-0.522 3.769,2.399 6.136,4.449 5.443,6.639 -0.596,1.884 -2.977,2.281 -5.925,2.281 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path77" /><path
d="m 64.43,97.056 c -1.063,0 -2.197,-0.051 -3.35,-0.104 -1.735,-0.077 -3.059,0.124 -3.912,-0.868 -1.647,-1.912 -0.764,-8.39 -0.57,-9.67 0.14,-0.935 1.002,-1.592 1.947,-1.436 0.935,0.141 1.578,1.014 1.436,1.947 -0.326,2.152 -0.474,5.221 -0.267,6.547 0.466,0.014 0.98,0.037 1.521,0.063 1.35,0.061 3.839,0.173 5.254,0.002 -0.534,-0.509 -1.537,-1.32 -3.415,-2.517 -0.796,-0.507 -1.032,-1.564 -0.523,-2.362 0.509,-0.794 1.564,-1.034 2.362,-0.522 3.769,2.399 6.136,4.447 5.443,6.639 -0.595,1.884 -2.977,2.281 -5.926,2.281 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path79" /><path
d="m 22.625,97.056 c -1.063,0 -2.197,-0.051 -3.351,-0.104 -1.652,-0.073 -2.938,0.145 -3.782,-0.776 -1.313,-1.432 -1.153,-5.736 -0.943,-8.172 0.083,-0.941 0.918,-1.635 1.853,-1.558 0.941,0.083 1.639,0.912 1.558,1.853 -0.183,2.085 -0.134,4.154 0.029,5.175 0.446,0.016 0.931,0.037 1.441,0.061 1.352,0.061 3.841,0.171 5.252,0.002 -0.534,-0.509 -1.537,-1.32 -3.415,-2.517 -0.796,-0.507 -1.032,-1.564 -0.523,-2.362 0.509,-0.794 1.566,-1.034 2.362,-0.522 3.769,2.399 6.136,4.449 5.443,6.639 -0.596,1.884 -2.977,2.281 -5.924,2.281 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path81" /><path
d="m 37.967,97.056 c -1.063,0 -2.197,-0.051 -3.351,-0.104 -1.654,-0.073 -2.938,0.145 -3.782,-0.776 -1.313,-1.432 -1.153,-5.736 -0.943,-8.172 0.083,-0.941 0.933,-1.635 1.853,-1.558 0.941,0.083 1.639,0.912 1.558,1.853 -0.183,2.085 -0.134,4.154 0.029,5.175 0.446,0.016 0.931,0.037 1.441,0.061 1.352,0.061 3.837,0.173 5.252,0.002 -0.532,-0.509 -1.537,-1.32 -3.415,-2.515 -0.796,-0.509 -1.032,-1.566 -0.525,-2.364 0.511,-0.794 1.568,-1.028 2.364,-0.524 3.769,2.401 6.138,4.449 5.445,6.641 -0.596,1.884 -2.977,2.281 -5.926,2.281 z"
fill="#d90000"
data-fill-palette-color="accent"
id="path83" /></g></svg>
</g>
</svg>
</g>
<rect
width="998.97418"
height="537.32062"
fill="none"
stroke="none"
visibility="hidden"
id="rect110"
x="-505.86829"
y="-173.03743"
style="stroke-width:2.66337" />
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,83 @@
/* Styling for the floating TOC */
#floating-toc {
position: fixed;
top: 50%;
right: 20px;
transform: translateY(-50%);
background-color: rgba(255, 255, 255, 0.72);
border: 1px solid rgba(64, 64, 64, 0.2); /* Set the border style */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
z-index: 9999;
height: 66%;
overflow-y: hide;
overflow-x: auto;
width: 240px;
}
/* Styling for TOC list items */
#floating-toc ul {
list-style-type: none;
padding-left: 26px;
margin-top: 36px;
line-height: 2px;
}
/* Styling for heading levels in TOC */
#floating-toc ul li {
/* no line breaks please */
width: 250%;
}
#floating-toc ul li a {
font-size: 14px;
font-weight: normal;
}
#floating-toc ul li h1 a {
font-weight: bold;
font-size: 16px;
}
#floating-toc ul li h2 a {
font-weight: bold;
}
#floating-toc ul li h3 a {
font-style: italic;
}
/* Styling for search input */
#floating-toc .search-container {
position: sticky;
top: 6px;
padding: 0px;
}
#floating-toc input[type="text"] {
width: 186px;
height: 24px;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 1.00);
color: rgba(128, 128, 128, 1.0); /* Set the text color */
border: 1px solid rgba(0, 0, 0, 0.2); /* Set the border style */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
#floating-toc input[type="button"] {
position: float;
width: 24px;
height: 24px;
padding: 0;
margin: 0;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.72);
color: rgba(128, 128, 128, 1.0); /* Set the text color */
border: 0px solid rgba(0, 0, 0, 0.2); /* Set the border style */
}
/* Highlighting current caption in TOC */
#floating-toc ul li a.active {
font-weight: bold;
}

View File

@@ -0,0 +1,98 @@
// JavaScript code for creating the floating TOC
window.addEventListener('DOMContentLoaded', function() {
var tocContainer = document.getElementById('floating-toc');
var showBtn = document.getElementById('toc-hide-show-btn');
var tocList = document.getElementById('toc-list');
var headings = document.querySelectorAll('h1, h2, h3');
var tocLevels = [0, 0, 0];
// Calculate the initial position of the TOC
const tocContainerRect = tocContainer.getBoundingClientRect();
const tocContainerRight = tocContainer.style.right;
const buttonText = document.getElementById('buttonText');
headings.forEach(function(heading) {
var level = parseInt(heading.tagName.substr(1), 10) - 1;
tocLevels[level]++;
for (var i = level + 1; i < 3; i++) {
tocLevels[i] = 0;
}
var listItem = document.createElement('li');
var link = document.createElement('a');
var number = tocLevels.slice(0, level + 1).join('.') + ' ';
link.textContent = number + heading.textContent.trim().replace(/#$/, '').replace(/¶$/, '');
var headingId = 'heading-' + Math.random().toString(36).substr(2, 9);
heading.setAttribute('id', headingId);
link.href = '#' + headingId;
var styledHeading = document.createElement('h' + (level + 1));
styledHeading.appendChild(link);
listItem.appendChild(styledHeading);
tocList.appendChild(listItem);
});
// Toggle TOC visibility
showBtn.addEventListener('click', function() {
if (tocContainer.style.right != tocContainerRight) {
tocContainer.style.right = tocContainerRight;
// buttonText.innerText="H";
} else {
tocContainer.style.right = `-${tocContainerRect.width-26}px`;
// buttonText.innerText="S";
};
});
// JavaScript code for searching the TOC
var searchInput = document.getElementById('toc-search');
var tocItems = Array.from(tocList.getElementsByTagName('li'));
searchInput.addEventListener('input', function() {
var searchValue = this.value.toLowerCase();
tocItems.forEach(function(item) {
var link = item.querySelector('a');
var linkText = link.textContent.toLowerCase();
if (linkText.includes(searchValue)) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
// JavaScript code for updating the floating TOC on scroll
window.addEventListener('scroll', function() {
var scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
var visibleHeading = null;
headings.forEach(function(heading) {
var rect = heading.getBoundingClientRect();
if (rect.top > 0 && rect.top < window.innerHeight) {
visibleHeading = heading;
return;
}
});
if (visibleHeading) {
var activeLink = tocList.querySelector('a[href="#' + visibleHeading.id + '"]');
if (activeLink) {
activeLink.classList.add('active');
tocContainer.scrollTop = activeLink.offsetTop - tocContainer.offsetTop;
}
// Remove 'active' class from other links
var allLinks = tocList.querySelectorAll('a');
allLinks.forEach(function(link) {
if (link !== activeLink) {
link.classList.remove('active');
}
});
}
});
});

View File

@@ -0,0 +1,74 @@
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #fff; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #06287e } /* Name.Function.Magic */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */

View File

@@ -0,0 +1,34 @@
div .ebnf
{
display: block;
padding: 2pt;
margin-bottom: 22pt;
font:10px 'Roboto-Mono',monospace;
}
@namespace "http://www.w3.org/2000/svg";
.line {fill: none; stroke: #0063db; stroke-width: 1;}
.bold-line {stroke: #000714; shape-rendering: crispEdges; stroke-width: 2;}
.thin-line {stroke: #000A1F; shape-rendering: crispEdges;}
.filled {fill: #0063db; stroke: none;}
text.terminal {font-family: Roboto, Sans-serif;
font-size: 10px;
fill: #000714;
font-weight: bold;
}
text.nonterminal {font-family: Roboto, Sans-serif;
font-size: 10px;
fill: #00091A;
font-weight: normal;
}
text.regexp {font-family: Roboto, Sans-serif;
font-size: 10px;
fill: #000A1F;
font-weight: normal;
}
rect, circle, polygon {fill: #0063db; stroke: #0063db;}
rect.terminal {fill: #4D88FF; stroke: #0063db; stroke-width: 1;}
rect.nonterminal {fill: #9EBFFF; stroke: #0063db; stroke-width: 1;}
rect.text {fill: none; stroke: none;}
polygon.regexp {fill: #C7DAFF; stroke: #0063db; stroke-width: 1;}

41
src/site/sphinx/conf.py Normal file
View File

@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# General options
needs_sphinx = '1.0'
add_function_parentheses = True
extensions = ['myst_parser', 'sphinx.ext.autodoc', 'sphinx.ext.autosectionlabel', 'sphinx.ext.extlinks', 'sphinx-prompt', 'sphinx_substitution_extensions', 'sphinx_inline_tabs', 'pygments.sphinxext', ]
issues_github_path = "JSQLParser/JSqlParser"
source_encoding = 'utf-8-sig'
#pygments_style = 'friendly'
show_sphinx = False
master_doc = 'index'
exclude_patterns = ['_themes', '_static/css']
logo_only = True
# HTML options
html_theme = "furo"
html_theme_path = ["_themes"]
html_short_title = "JSQLParser"
htmlhelp_basename = "JSQLParser" + '-doc'
html_use_index = True
html_show_sourcelink = False
html_static_path = ['_static']
html_logo = '_images/logo-no-background.svg'
html_favicon = '_images/favicon.svg'
html_css_files = ['svg.css', 'floating_toc.css']
html_js_files = ['floating_toc.js',]
html_theme_options = {
'path_to_docs': 'site/sphinx',
'repository_url': 'https://github.com/JSQLParser/JSqlParser',
'repository_branch': 'master',
'use_issues_button': True,
'use_download_button': True,
'use_fullscreen_button': True,
'use_repository_button': True,
}

View File

@@ -0,0 +1,168 @@
******************************
How to contribute
******************************
Error Reports
==============================
Please report any issue to the `GitHub Issue Tracker <https://github.com/JSQLParser/JSqlParser/issues>`_:
1) Provide the **Sample SQL** (shortened and simplified, properly formatted)
2) State the exact **Version of JSQLParser**
3) State the **RDBMS** in use and point on the applicable Grammar specification
4) Please write in **English** and post **Plain Text only** (avoiding screen shots or bitmap pictures).
Before reporting any issues, please verify your statement using `JSQLFormatter Online <http://jsqlformatter.manticore-projects.com>`_.
Feature Requests
==============================
JSQLParser is a demand-driven software library, where many contributors have shared solutions for their own needs. Requests for new features have a good chance to get implemented when
1) the request is about a commonly used feature for one of the major RDBMS
2) or the request is backed by a sponsor or a bounty, which may attract developers to spend their time on it.
Implementing new Features
==============================
The team around JSQLParser warmly welcomes Code Contributions and Pull Requests. Please follow the guidance below and do not hesitate to ask us for assistance.
Create a new Git Branch
------------------------------
When starting afresh, clone `JSQLParser` from the `GitHub` repository:
.. code-block:: Bash
git clone https://github.com/JSQLParser/JSqlParser.git
cd JSqlParser
git branch <new-branch>
When having a local repository already, then pull/merge from the `GitHub` repository:
.. code-block:: Bash
cd JSqlParser
git pull origin master
git branch <new-branch>
Amend the Code
------------------------------
The JSQLParser is generated by ``JavaCC`` based on the provided Grammar. The Grammar defines how a SQL Text is read and translated into Java Objects. Thus any contribution will depend on the following steps:
1) Edit the ``JavaCC`` Grammar at ``src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt``
2) Add or edit the Java Classes at ``src/main/java/net/sf/jsqlparser`` to facilitate this Grammar.
3) When have added new Java Classes, amend the Visitors, the Visitor Adaptors, the De-Parsers and the Validators.
4) Provide Java Unit Tests at ``src/test/java/net/sf/jsqlparser`` to test the new feature
* The test should call at least one time the method ``assertSqlCanBeParsedAndDeparsed()``
* The test should ensure complete coverage of the new Java Classes.
* The complete test suite must succeed.
5) Add the description of the new feature to the ``README.md`` file, section `Extensions`.
6) Build the package with ``Maven`` and ensure, all checks do pass (PMD and CheckStyle and Code Formatting).
Manage Reserved Keywords
------------------------------
Since JSQLParser is built by JavaCC from a Token based Grammar, ``Reserved Keywords`` need a special treatment. All Tokens of the Grammar would become ``Reserved Keywords`` -- unless explicitly allowed and white-listened.
.. code-block:: sql
:caption: White-list Keyword example
-- <K_OVERLAPS:"OVERLAPS"> is a Token, recently defined in the Grammar
-- Although it is not restricted by the SQL Standard and could be used for Column, Table and Alias names
-- Explicitly white-listing OVERLAPS by adding it to the RelObjectNameWithoutValue() Production will allow for parsing the following statement
SELECT Overlaps( overlaps ) AS overlaps
FROM overlaps.overlaps overlaps
WHERE overlaps = 'overlaps'
AND (CURRENT_TIME, INTERVAL '1' HOUR) OVERLAPS (CURRENT_TIME, INTERVAL -'1' HOUR)
;
So we will need to define and white-list any Keywords which may be allowed for Object Names (such as `Schema`, `Table`, `Column`, `Function`, `Alias`). This White-List must be updated whenever the Tokens of the Grammar change (e. |_| g. when adding a new Token or Production).
There is a task ``updateKeywords`` for Gradle and Maven, which will:
1) Parse the Grammar in order to find all Token definitions
2) Read the list of explicitly ``Reserved Keywords`` from ``net/sf/jsqlparser/parser/ParserKeywordsUtils.java``
3) Derive the list of ``White-Listed Keywords`` as difference between ``All Tokens`` and ``Reserved Keywords``
4) Modifies the Grammar Productions ``RelObjectNameWithoutValue...`` adding all Tokens according to ``White-Listed Keywords``
5) Run two special Unit Tests to verify parsing of all ``White-Listed Keywords`` (as `Schema`, `Table`, `Column`, `Function` or `Alias`)
6) Update the web page about the Reserved Keywords
.. tab:: Gradle
.. code-block:: shell
:caption: Gradle `updateKeywords` Task
gradle updateKeywords
.. tab:: Maven
.. code-block:: shell
:caption: Maven `updateKeywords` Task
mvn exec:java
Without this Gradle Task, any new Token or Production will become a ``Reserved Keyword`` automatically and can't be used for Object Names without quoting.
Commit a Pull Request
---------------------------------
.. code-block:: Bash
cd JSqlParser
git add -A
git commit -m <title> -m <description>
git push set-upstream origin <new-branch>
Follow the advice on `Meaningful Commit Messages <https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/>`_ and consider using `Commitizen <https://commitizen-tools.github.io/commitizen/>`_ when describing your commits.
Please consider using `Conventional Commits` and structure your commit message as follows:
.. code-block:: text
:caption: Conventional Commit Message Structure
<type>[optional scope]: <description>
[optional body]
[BREAKING CHANGE: <change_description>]
[optional footer(s)]
.. list-table:: Commit Message Types
:widths: 15 85
:header-rows: 1
* - Type
- Description
* - **feat**
- introduce a new feature
* - **fix**
- patches a bug in your codebase (bugfix or hotfix)
* - **build**
- changes that affect the build system or external dependencies
* - **chore**
- updates dependencies and does not relate to fix or feat and does not modify src or test files.
* - **ci**
- changes that affect the continuous integration process
* - **docs**
- updates the documentation or introduce documentation
* - **style**
- updates the formatting of code; remove white spaces, add missing spaces, remove unnecessary newlines
* - **refactor**
- reactors code segments to optimize readability without changing behavior
* - **perf**
- improve performance
* - **test**
- add/remove/update tests
* - **revert**
- reverts one or many previous commits
Please visit `Better Programming <https://betterprogramming.pub/write-better-git-commit-messages-to-increase-your-productivity-89fa773e8375>`_ for more information and guidance.

115
src/site/sphinx/index.rst Normal file
View File

@@ -0,0 +1,115 @@
.. meta::
:description: Java Software Library for parsing SQL Statements into Abstract Syntax Trees (AST) and manipulation of SQL Statements
:keywords: java sql statement parser abstract syntax tree
###########################
Java SQL Parser Library
###########################
.. toctree::
:maxdepth: 2
:hidden:
usage
contribution
migration47
migration50
SQL Grammar Stable <syntax_stable>
SQL Grammar Snapshot <syntax_snapshot>
Unsupported Grammar <unsupported>
Java API Stable <javadoc_stable>
Java API Snapshot <javadoc_snapshot>
keywords
changelog
.. image:: https://img.shields.io/github/release/JSQLParser/JSqlParser?include_prereleases=&sort=semver&color=blue
:alt: GitGub Release Badge
:target: https://github.com/JSQLParser/JSqlParser/releases
.. image:: https://img.shields.io/github/issues/JSQLParser/JSqlParser
:alt: GitGub Issues Badge
:target: https://github.com/JSQLParser/JSqlParser/issues
.. image:: https://badgen.net/maven/v/maven-central/com.github.jsqlparser/jsqlparser
:alt: Maven Badge
:target: https://mvnrepository.com/artifact/com.github.jsqlparser/jsqlparser
.. image:: https://github.com/JSQLParser/JSqlParser/actions/workflows/maven.yml/badge.svg
:alt: Maven Build Status
:target: https://github.com/JSQLParser/JSqlParser/actions/workflows/maven.yml
.. image:: https://coveralls.io/repos/JSQLParser/JSqlParser/badge.svg?branch=master
:alt: Coverage Status
:target: https://coveralls.io/github/com.github.jsqlparser/jsqlparser?branch=master
.. image:: https://app.codacy.com/project/badge/Grade/6f9a2d7eb98f45969749e101322634a1
:alt: Codacy Status
:target: https://app.codacy.com/gh/com.github.jsqlparser/jsqlparser/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
.. image:: https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg
:alt: Java Docs
:target: https://javadoc.io/doc/com.github.jsqlparser/jsqlparser/latest/index.html
**JSQLParser** is a SQL statement parser built from JavaCC. It translates SQLs in a traversable hierarchy of Java classes.
The upcoming 5.0 release will depend on Java 11 and introduces new Visitors. Please see the :ref:`Migration to 5.0` guide.
Latest stable release: |JSQLPARSER_STABLE_VERSION_LINK|
Development version: |JSQLPARSER_SNAPSHOT_VERSION_LINK|
.. sidebar:: Java API Website
.. image:: _images/JavaAST.png
.. code-block:: SQL
:caption: Sample SQL Statement
SELECT /*+ PARALLEL */
cfe.id_collateral_ref.nextval
, id_collateral
FROM ( SELECT DISTINCT
a.id_collateral
FROM cfe.collateral a
LEFT JOIN cfe.collateral_ref b
ON a.id_collateral = b.id_collateral
WHERE b.id_collateral_ref IS NULL )
;
******************************
SQL Dialects
******************************
**JSqlParser** is RDBMS agnostic and provides support for many dialects such as:
* Oracle Database
* MS SqlServer
* MySQL and MariaDB
* PostgreSQL
* H2
*******************************
Features
*******************************
* Comprehensive support for statements:
- QUERY: ``SELECT ...``
- DML: ``INSERT ... INTO ...`` ``UPDATE ...`` ``MERGE ... INTO ...`` ``DELETE ... FROM ...``
- DDL: ``CREATE ...`` ``ALTER ...`` ``DROP ...``
* Nested Expressions (e.g. Sub-Selects)
* ``WITH`` clauses
* Old Oracle ``JOIN (+)``
* PostgreSQL implicit ``CAST ::``
* SQL Parameters (e.g. ``?`` or ``:parameter``)
* Arrays vs. T-SQL Squared Bracket Quotes
* Fluent API to create SQL Statements from java Code
* Statement De-Parser to write SQL from Java Objects

View File

@@ -0,0 +1,241 @@
***********************
Restricted Keywords
***********************
The following Keywords are **restricted** in JSQLParser-|JSQLPARSER_VERSION| and must not be used for **Naming Objects**:
+----------------------+-------------+-----------+
| **Keyword** | JSQL Parser | SQL:2016 |
+----------------------+-------------+-----------+
| ABSENT | Yes | Yes |
+----------------------+-------------+-----------+
| ALL | Yes | Yes |
+----------------------+-------------+-----------+
| AND | Yes | Yes |
+----------------------+-------------+-----------+
| ANY | Yes | Yes |
+----------------------+-------------+-----------+
| AS | Yes | Yes |
+----------------------+-------------+-----------+
| BETWEEN | Yes | Yes |
+----------------------+-------------+-----------+
| BOTH | Yes | Yes |
+----------------------+-------------+-----------+
| CASEWHEN | Yes | |
+----------------------+-------------+-----------+
| CHECK | Yes | Yes |
+----------------------+-------------+-----------+
| CONNECT | Yes | |
+----------------------+-------------+-----------+
| CONNECT_BY_ROOT | Yes | Yes |
+----------------------+-------------+-----------+
| CONSTRAINT | Yes | Yes |
+----------------------+-------------+-----------+
| CREATE | Yes | |
+----------------------+-------------+-----------+
| CROSS | Yes | Yes |
+----------------------+-------------+-----------+
| CURRENT | Yes | Yes |
+----------------------+-------------+-----------+
| DISTINCT | Yes | Yes |
+----------------------+-------------+-----------+
| DOUBLE | Yes | |
+----------------------+-------------+-----------+
| ELSE | Yes | Yes |
+----------------------+-------------+-----------+
| EXCEPT | Yes | Yes |
+----------------------+-------------+-----------+
| EXCLUDES | Yes | Yes |
+----------------------+-------------+-----------+
| EXISTS | Yes | Yes |
+----------------------+-------------+-----------+
| FETCH | Yes | Yes |
+----------------------+-------------+-----------+
| FINAL | Yes | Yes |
+----------------------+-------------+-----------+
| FOR | Yes | Yes |
+----------------------+-------------+-----------+
| FORCE | Yes | Yes |
+----------------------+-------------+-----------+
| FOREIGN | Yes | Yes |
+----------------------+-------------+-----------+
| FROM | Yes | Yes |
+----------------------+-------------+-----------+
| FULL | Yes | Yes |
+----------------------+-------------+-----------+
| GLOBAL | Yes | |
+----------------------+-------------+-----------+
| GROUP | Yes | Yes |
+----------------------+-------------+-----------+
| GROUPING | Yes | |
+----------------------+-------------+-----------+
| QUALIFY | Yes | |
+----------------------+-------------+-----------+
| HAVING | Yes | Yes |
+----------------------+-------------+-----------+
| IF | Yes | Yes |
+----------------------+-------------+-----------+
| IIF | Yes | |
+----------------------+-------------+-----------+
| IGNORE | Yes | |
+----------------------+-------------+-----------+
| ILIKE | Yes | Yes |
+----------------------+-------------+-----------+
| IN | Yes | Yes |
+----------------------+-------------+-----------+
| INCLUDES | Yes | Yes |
+----------------------+-------------+-----------+
| INNER | Yes | Yes |
+----------------------+-------------+-----------+
| INTERSECT | Yes | Yes |
+----------------------+-------------+-----------+
| INTERVAL | Yes | Yes |
+----------------------+-------------+-----------+
| INTO | Yes | Yes |
+----------------------+-------------+-----------+
| IS | Yes | Yes |
+----------------------+-------------+-----------+
| JOIN | Yes | Yes |
+----------------------+-------------+-----------+
| LATERAL | Yes | Yes |
+----------------------+-------------+-----------+
| LEFT | Yes | Yes |
+----------------------+-------------+-----------+
| LIKE | Yes | Yes |
+----------------------+-------------+-----------+
| LIMIT | Yes | Yes |
+----------------------+-------------+-----------+
| MINUS | Yes | Yes |
+----------------------+-------------+-----------+
| NATURAL | Yes | Yes |
+----------------------+-------------+-----------+
| NOCYCLE | Yes | Yes |
+----------------------+-------------+-----------+
| NOT | Yes | Yes |
+----------------------+-------------+-----------+
| NULL | Yes | Yes |
+----------------------+-------------+-----------+
| OFFSET | Yes | Yes |
+----------------------+-------------+-----------+
| ON | Yes | Yes |
+----------------------+-------------+-----------+
| ONLY | Yes | Yes |
+----------------------+-------------+-----------+
| OPTIMIZE | Yes | |
+----------------------+-------------+-----------+
| OR | Yes | Yes |
+----------------------+-------------+-----------+
| ORDER | Yes | Yes |
+----------------------+-------------+-----------+
| OUTER | Yes | Yes |
+----------------------+-------------+-----------+
| OUTPUT | Yes | Yes |
+----------------------+-------------+-----------+
| OPTIMIZE | Yes | Yes |
+----------------------+-------------+-----------+
| PIVOT | Yes | Yes |
+----------------------+-------------+-----------+
| PROCEDURE | Yes | |
+----------------------+-------------+-----------+
| PUBLIC | Yes | |
+----------------------+-------------+-----------+
| RETURNING | Yes | Yes |
+----------------------+-------------+-----------+
| RIGHT | Yes | Yes |
+----------------------+-------------+-----------+
| SAMPLE | Yes | |
+----------------------+-------------+-----------+
| SEL | Yes | |
+----------------------+-------------+-----------+
| SELECT | Yes | |
+----------------------+-------------+-----------+
| SEMI | Yes | Yes |
+----------------------+-------------+-----------+
| SET | Yes | Yes |
+----------------------+-------------+-----------+
| SOME | Yes | Yes |
+----------------------+-------------+-----------+
| START | Yes | Yes |
+----------------------+-------------+-----------+
| TABLES | Yes | |
+----------------------+-------------+-----------+
| TOP | Yes | Yes |
+----------------------+-------------+-----------+
| TRAILING | Yes | Yes |
+----------------------+-------------+-----------+
| UNBOUNDED | Yes | Yes |
+----------------------+-------------+-----------+
| UNION | Yes | Yes |
+----------------------+-------------+-----------+
| UNIQUE | Yes | Yes |
+----------------------+-------------+-----------+
| UNPIVOT | Yes | Yes |
+----------------------+-------------+-----------+
| USE | Yes | Yes |
+----------------------+-------------+-----------+
| USING | Yes | Yes |
+----------------------+-------------+-----------+
| SQL_CACHE | Yes | Yes |
+----------------------+-------------+-----------+
| SQL_CALC_FOUND_ROWS | Yes | Yes |
+----------------------+-------------+-----------+
| SQL_NO_CACHE | Yes | Yes |
+----------------------+-------------+-----------+
| STRAIGHT_JOIN | Yes | Yes |
+----------------------+-------------+-----------+
| TABLESAMPLE | Yes | |
+----------------------+-------------+-----------+
| VALUE | Yes | Yes |
+----------------------+-------------+-----------+
| VALUES | Yes | Yes |
+----------------------+-------------+-----------+
| VARYING | Yes | Yes |
+----------------------+-------------+-----------+
| WHEN | Yes | Yes |
+----------------------+-------------+-----------+
| WHERE | Yes | Yes |
+----------------------+-------------+-----------+
| WINDOW | Yes | Yes |
+----------------------+-------------+-----------+
| WITH | Yes | Yes |
+----------------------+-------------+-----------+
| XOR | Yes | Yes |
+----------------------+-------------+-----------+
| XMLSERIALIZE | Yes | Yes |
+----------------------+-------------+-----------+
| SEL | Yes | Yes |
+----------------------+-------------+-----------+
| SELECT | Yes | Yes |
+----------------------+-------------+-----------+
| DATE | Yes | Yes |
+----------------------+-------------+-----------+
| TIME | Yes | Yes |
+----------------------+-------------+-----------+
| TIMESTAMP | Yes | Yes |
+----------------------+-------------+-----------+
| YEAR | Yes | Yes |
+----------------------+-------------+-----------+
| MONTH | Yes | Yes |
+----------------------+-------------+-----------+
| DAY | Yes | Yes |
+----------------------+-------------+-----------+
| HOUR | Yes | Yes |
+----------------------+-------------+-----------+
| MINUTE | Yes | Yes |
+----------------------+-------------+-----------+
| SECOND | Yes | Yes |
+----------------------+-------------+-----------+
| SUBSTR | Yes | Yes |
+----------------------+-------------+-----------+
| SUBSTRING | Yes | Yes |
+----------------------+-------------+-----------+
| TRIM | Yes | Yes |
+----------------------+-------------+-----------+
| POSITION | Yes | Yes |
+----------------------+-------------+-----------+
| OVERLAY | Yes | Yes |
+----------------------+-------------+-----------+
| NEXTVAL | Yes | |
+----------------------+-------------+-----------+
| 0x | Yes | Yes |
+----------------------+-------------+-----------+

View File

@@ -0,0 +1,387 @@
*********************************
Migration to 4.7
*********************************
The new version of JSQLParser 4.7 is a rewrite in order to simplify accessing the SQL's Abstract Syntax Tree (AST). Quite a few redundant classes have been removed or merged.
As always, such a major improvement comes at a certain cost, which is breaking the previous API. Following the guidance below, the new API can be adopted easily although you are welcome to lodge a support request when any questions or concerns arise.
`Values` Clause
---------------------------------
The ``ValueListExpression`` has been replaced by ``Values``, which implements ``Select`` `Statement` and `Expression`.
The ``ValuesStatement`` has been replaced by ``Values``, which implements ``Select`` `Statement` and `Expression`.
.. tab:: Statement
.. code-block:: SQL
VALUES ( 1, 2, 3 )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.Values
└─ParenthesedExpressionList: (1, 2, 3)
.. code-block:: JAVA
Values values = (Values) CCJSqlParserUtil.parse(sqlStr);
assertEquals( 3, values.getExpressions().size() );
.. tab:: Sub-query
.. code-block:: SQL
SELECT *
FROM ( VALUES 1, 2, 3 )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.PlainSelect
├─selectItems: statement.select.SelectItem
│ └─AllColumns: *
└─fromItem: statement.select.ParenthesedSelect
└─select: statement.select.Values
└─ExpressionList: 1, 2, 3
.. code-block:: JAVA
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);
ParenthesedSelect subSelect = (ParenthesedSelect) select.getFromItem();
Values values = (Values) subSelect.getSelect();
assertEquals( 3, values.getExpressions().size() );
.. tab:: Expression
.. code-block:: SQL
UPDATE test
SET ( a
, b
, c ) = ( VALUES 1, 2, 3 )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.update.Update
├─Table: test
└─updateSets: statement.update.UpdateSet
├─ParenthesedExpressionList: (a, b, c)
└─ExpressionList: (VALUES 1, 2, 3)
.. code-block:: JAVA
Update update = (Update) CCJSqlParserUtil.parse(sqlStr);
UpdateSet updateSet = update.getUpdateSets().get(0);
ParenthesedSelect subSelect = (ParenthesedSelect) updateSet.getValues().get(0);
Values values = (Values) subSelect.getSelect();
assertEquals( 3, values.getExpressions().size() );
.. tab:: Clause
.. code-block:: SQL
INSERT INTO test
VALUES ( 1, 2, 3 )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.insert.Insert
├─Table: test
└─select: statement.select.Values
└─ParenthesedExpressionList: (1, 2, 3)
.. code-block:: JAVA
Insert insert = (Insert) CCJSqlParserUtil.parse(sqlStr);
Values values = (Values) insert.getSelect();
Assertions.assertEquals(3, values.getExpressions().size());
`Expression` Lists
---------------------------------
The class ``ExpressionList`` extends ``List<Expression>`` directly and so ``ExpressionList.getExpressions()`` is obsolete.
Any instance of `List<Expression>` is considered an Anti Pattern and the class ``ExpressionList<T extends Expression>`` shall be used instead.
``ItemsList`` has been removed and ``ExpressionList`` is used instead.
``MultiExpressionList`` has been removed and ``ExpressionList`` is used instead (with ``ExpressionList`` elements).
.. tab:: ExpressionList
.. code-block:: SQL
SELECT Function( a, b, c )
FROM dual
GROUP BY a
, b
, c
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.PlainSelect
├─selectItems: statement.select.SelectItem
│ └─expression: expression.Function
│ └─ExpressionList: a, b, c
├─Table: dual
└─groupBy: statement.select.GroupByElement
└─ExpressionList: a, b, c
.. code-block:: JAVA
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);
Function function = (Function) select.getSelectItem(0).getExpression();
assertEquals(3, function.getParameters().size());
ExpressionList<?> groupByExpressions=select.getGroupBy().getGroupByExpressionList();
assertEquals(3, groupByExpressions.size());
.. tab:: Wrapped ExpressionList
.. code-block:: SQL
SELECT ( ( 1, 2, 3 ), ( 4, 5, 6 ), ( 7, 8, 9 ) )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.PlainSelect
└─selectItems: statement.select.SelectItem
└─ParenthesedExpressionList: ((1, 2, 3), (4, 5, 6), (7, 8, 9))
.. code-block:: JAVA
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);
ParenthesedExpressionList<?> expressionList = (ParenthesedExpressionList<?>) select.getSelectItem(0).getExpression();
ParenthesedExpressionList<?> expressionList1 = (ParenthesedExpressionList<?>) expressionList.get(0);
assertEquals(3, expressionList1.size());
Generic `SelectItem`
---------------------------------
The class ``SelectItem<T extends Expression>`` is now generic and various derivatives (e. |_| g. ``SelectExpressionItem``, ``FunctionItem``, ``ExpressionListItem``) have been removed.
`Select` Statement
---------------------------------
``SelectBody`` has been removed and ``PlainSelect`` can be used directly
``SubJoin`` has been replaced by ``ParenthesedFromItem`` (implementing a ``FromItem`` with a regular list of ``Join``)
``SubSelect`` has been removed and any instance of ``Select`` (``PlainSelect``, ``Values`` or ``SetOperationList``) can be used instead
.. tab:: Select
.. code-block:: SQL
(
SELECT *
FROM ( SELECT 1 )
UNION ALL
SELECT *
FROM ( VALUES 1, 2, 3 )
UNION ALL
VALUES ( 1, 2, 3 ) )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.ParenthesedSelect
└─select: statement.select.SetOperationList
├─selects: statement.select.PlainSelect
│ ├─selectItems: statement.select.SelectItem
│ │ └─AllColumns: *
│ └─fromItem: statement.select.ParenthesedSelect
│ └─select: statement.select.PlainSelect
│ └─selectItems: statement.select.SelectItem
│ └─LongValue: 1
├─selects: statement.select.PlainSelect
│ ├─selectItems: statement.select.SelectItem
│ │ └─AllColumns: *
│ └─fromItem: statement.select.ParenthesedSelect
│ └─select: statement.select.Values
│ └─ExpressionList: 1, 2, 3
├─selects: statement.select.Values
│ └─ParenthesedExpressionList: (1, 2, 3)
├─UnionOp: UNION ALL
└─UnionOp: UNION ALL
.. code-block:: JAVA
ParenthesedSelect parenthesedSelect = (ParenthesedSelect) CCJSqlParserUtil.parse(sqlStr);
SetOperationList setOperationList = parenthesedSelect.getSetOperationList();
PlainSelect select1 = (PlainSelect) setOperationList.getSelect(0);
PlainSelect subSelect1 = ((ParenthesedSelect) select1.getFromItem()).getPlainSelect();
Assertions.assertEquals( 1L, subSelect1.getSelectItem(0).getExpression(LongValue.class).getValue());
Values values = (Values) setOperationList.getSelect(2);
Assertions.assertEquals( 3, values.getExpressions().size());
.. tab:: Join
.. code-block:: SQL
SELECT *
FROM a
INNER JOIN ( b
LEFT JOIN c
ON b.d = c.d )
ON a.e = b.e
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.PlainSelect
├─selectItems: statement.select.SelectItem
│ └─AllColumns: *
├─Table: a
└─joins: statement.select.Join
├─rightItem: statement.select.ParenthesedFromItem
│ ├─Table: b
│ └─joins: statement.select.Join
│ ├─Table: c
│ └─onExpressions: expression.operators.relational.EqualsTo
│ ├─Column: b.d
│ └─Column: c.d
└─onExpressions: expression.operators.relational.EqualsTo
├─Column: a.e
└─Column: b.e
.. code-block:: JAVA
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);
Table aTable = (Table) select.getFromItem();
ParenthesedFromItem fromItem = (ParenthesedFromItem) select.getJoin(0).getFromItem();
Table bTable = (Table) fromItem.getFromItem();
Join join = fromItem.getJoin(0);
Table cTable = (Table) join.getFromItem();
assertEquals("c", cTable.getName());
Brackets
---------------------------------
Any `hasBrackets()`, `isUsingBrackets()` and similar methods have been removed; instead the Parser will return a ``ParenthesedExpressionList`` or ``ParenthesedSelect`` or ``ParenthesedFromItem`` or ``Parenthesis`` wrapping the object within brackets.
This allows for much better bracket handling.
.. code-block:: SQL
:caption: `Parenthesis` and Brackets example
( SELECT ( 1 ) )
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.select.ParenthesedSelect
└─select: statement.select.PlainSelect
└─selectItems: statement.select.SelectItem
└─expression: expression.Parenthesis
└─LongValue: 1
.. code-block:: JAVA
ParenthesedSelect parenthesedSelect = (ParenthesedSelect) CCJSqlParserUtil.parse(sqlStr);
SetOperationList setOperationList = parenthesedSelect.getSetOperationList();
PlainSelect select1 = (PlainSelect) setOperationList.getSelect(0);
PlainSelect subSelect1 = ((ParenthesedSelect) select1.getFromItem()).getPlainSelect();
Assertions.assertEquals( 1L, subSelect1.getSelectItem(0).getExpression(LongValue.class).getValue());
Values values = (Values) setOperationList.getSelect(2);
Assertions.assertEquals( 3, values.getExpressions().size());
`UpdateSet` clause
---------------------------------
A ``List<UpdateSet>`` is used for any `Set` clause within `Insert`, `Update`, `Upsert` or `Merge` statements.
.. code-block:: SQL
:caption: `UpdateSet` example
UPDATE a
SET ( a
, b
, c ) = ( 1
, 2
, 3 )
, d = 4
;
.. code-block:: TEXT
SQL Text
└─Statements: statement.update.Update
├─Table: a
├─updateSets: statement.update.UpdateSet
│ ├─ParenthesedExpressionList: (a, b, c)
│ └─ParenthesedExpressionList: (1, 2, 3)
└─updateSets: statement.update.UpdateSet
├─ExpressionList: d
└─ExpressionList: 4
.. code-block:: JAVA
Update update = (Update) CCJSqlParserUtil.parse(sqlStr);
UpdateSet updateSet1 = update.getUpdateSet(0);
Assertions.assertEquals( 3, updateSet1.getColumns().size());
Assertions.assertEquals( 3, updateSet1.getValues().size());
UpdateSet updateSet2 = update.getUpdateSet(1);
Assertions.assertEquals( "d", updateSet2.getColumn(0).getColumnName());
Assertions.assertEquals( 4L, ((LongValue) updateSet2.getValue(0)).getValue() );
`Statements` collection
---------------------------------
The ``Statements`` class extends `List<Statement>` directly and so `Statements.getStatements()` is obsolete.

View File

@@ -0,0 +1,96 @@
*********************************
Migration to 5.0
*********************************
The new JSQLParser 5 introduces API-breaking changes:
1. **Dependency on Java 11 or newer**
2. **Reworked AST Visitors**
The AST Visitors have been reworked to pass a Generic Context from the Root Node down to the Leaves.
.. code-block:: java
:caption: Generic Interface
public interface SelectVisitor<T> {
<S> T visit(PlainSelect plainSelect, S context);
default void visit(PlainSelect plainSelect) {
this.visit(plainSelect, null);
}
}
.. code-block:: java
:caption: Sample Implementation
public class JSQLColumnResolver
implements SelectVisitor<JdbcResultSetMetaData>, FromItemVisitor<JdbcResultSetMetaData> {
@Override
public <S> JdbcResultSetMetaData visit(PlainSelect select, S context) {
if (context instanceof JdbcMetaData) {
return visit(select, (JdbcMetaData) context);
}
return null;
}
public JdbcResultSetMetaData visit(PlainSelect select, JdbcMetaData metaData) {
JdbcResultSetMetaData resultSetMetaData = new JdbcResultSetMetaData();
// Logic to retrieve the column information
resultSetMetaData = getColumn(metaData, select.getFromItem(), select.getJoins());
return resultSetMetaData;
}
}
3. **Generic Result from Leaves to Root**
Node objects now return a Generic Result from the Leaves up to the Root.
.. code-block:: java
:caption: AST Node
public class PlainSelect extends Select {
@Override
public <T, S> T accept(SelectVisitor<T> selectVisitor, S context) {
return selectVisitor.visit(this, context);
}
}
How is this useful? Consider resolving the `AllColumns` ``*`` or `AllTableColumns` ``t.*`` expressions to retrieve the actual column names. This process depends on the database's physical metadata and the context of the current scope, including virtual data frames (like sub-selects and with-clauses).
Therefore, every branch of the AST must receive scoped metadata from its parent node. Each AST node must receive the resolved columns from its child nodes. A global result object (like the `StringBuilder` in the `DepParser` implementations) is inadequate.
Alternatively, consider substituting `TimeValueKey` (``CURRENT_DATE``, ``CURRENT_TIME``, etc.) with actual date or time values. You can push a simple `Map` of key/value pairs down to the Expression Visitor:
.. code-block:: java
:caption: Expression Visitor
@Override
public <S> StringBuilder visit(TimeKeyExpression expression, S context) {
if (context instanceof Map) {
return visit(expression, (Map<String, Object>) substitutions);
} else {
return expression.toString();
}
}
public StringBuilder visit(TimeKeyExpression expression, Map<String, Object> substitutions) {
// Remove possible trailing brackets "()"
String value = expression.getStringValue().toUpperCase().replaceAll("[()]", "");
if (substitutions.containsKey(value)) {
// @todo: Cast Date/Time types
return castDateTime(substitutions.get(value).toString()).accept(this, null);
} else {
return super.visit(expression, null);
}
}
Another advantage is parallel processing: Without relying on a global result object, the AST can be traversed in parallel (whereas it currently must be traversed strictly in serial).
Finally, any child node can now know its parent and identify who called it.

View File

@@ -0,0 +1,57 @@
***************************************
Unsupported Grammar of various RDBMS
***************************************
*JSQLParser* is a RDBMS agnostic parser with a certain focus on SQL:2016 Standard compliant Queries and the "Big Four" (Oracle, MS SQL Server, Postgres, MySQL/MariaDB).
We would like to recommend writing portable, standard compliant SQL in general.
- Postgres Implicit cast is not supported.
.. code-block:: java
SELECT date '2022-12-31';
SELECT double precision 1;
- Oracle PL/SQL blocks are not support.
.. code-block:: sql
DECLARE
num NUMBER;
BEGIN
num := 10;
dbms_output.put_line('The number is ' || num);
END;
- Oracle `INSERT ALL ...` is not supported
.. code-block:: sql
INSERT ALL
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
SELECT * FROM dual;
- DDL statements
While *JSQLParser* provides a lot of generic support for DDL statements, it is possible that certain RDBMS specific syntax (especially about indices, encodings, compression) won't be supported.
- `JSON` or `XML` specific syntax and functions
While *JSQLParser* provides a lot of generic support for `JSON` or `XML` processing, it is possible that certain RDBMS specific syntax or functions won't be supported.
- Interval Operators
Anything like `DAY HOUR MINUTE SECOND [TO HOUR MINUTE SECOND]` is not supported.:
.. code-block:: sql
values cast ((time '12:03:34' - time '11:57:23') minute to second as varchar(8));

320
src/site/sphinx/usage.rst Normal file
View File

@@ -0,0 +1,320 @@
******************************
How to use it
******************************
.. hint::
1) **Quoting:** Double Quotes ``".."`` are used for quoting identifiers. Parsing T-SQL on **MS SQL Server** or **Sybase** with Squared Brackets ``[..]`` depends on ``Squared Bracket Quotation`` as shown in section :ref:`Define the Parser Features` below.
2) JSQLParser uses a more restrictive list of ``Reserved Keywords`` and such keywords will **need to be quoted**.
3) **Escaping:** JSQLParser pre-defines standard compliant **Single Quote** ``'..`` **Escape Character**. Additional Back-slash ``\..`` Escaping needs to be activated by setting the ``BackSlashEscapeCharacter`` parser feature. See section :ref:`Define the Parser Features` below for details.
4) Oracle Alternative Quoting is partially supported for common brackets such as ``q'{...}'``, ``q'[...]'``, ``q'(...)'`` and ``q''...''``.
5) Supported Statement Separators are Semicolon ``;``, ``GO``, Slash ``/`` or two empty lines ``\n\n\n``.
Compile from Source Code
==============================
You will need to have ``JDK 8`` or ``JDK 11`` installed. Please note that JSQLParser-4.9 is the last ``JDK 8`` compatible release and all development after will depend on ``JDK 11``.
.. tab:: Maven
.. code-block:: shell
git clone https://github.com/JSQLParser/JSqlParser.git
cd jsqlformatter
mvn install
.. tab:: Gradle
.. code-block:: shell
git clone https://github.com/JSQLParser/JSqlParser.git
cd jsqlformatter
gradle publishToMavenLocal
Build Dependencies
==============================
.. tab:: Maven Release
.. code-block:: xml
:substitutions:
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>|JSQLPARSER_VERSION|</version>
</dependency>
.. tab:: Maven Snapshot
.. code-block:: xml
:substitutions:
<repositories>
<repository>
<id>jsqlparser-snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>|JSQLPARSER_SNAPSHOT_VERSION|</version>
</dependency>
.. tab:: Gradle Stable
.. code-block:: groovy
:substitutions:
repositories {
mavenCentral()
}
dependencies {
implementation 'com.github.jsqlparser:jsqlparser:|JSQLPARSER_VERSION|'
}
.. tab:: Gradle Snapshot
.. code-block:: groovy
:substitutions:
repositories {
maven {
url = uri('https://oss.sonatype.org/content/groups/public/')
}
}
dependencies {
implementation 'com.github.jsqlparser:jsqlparser:|JSQLPARSER_SNAPSHOT_VERSION|'
}
Parse a SQL Statement
==============================
Parse the SQL Text into Java Objects:
.. code-block:: java
String sqlStr = "select 1 from dual where a=b";
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);
SelectItem selectItem =
select.getSelectItems().get(0);
Assertions.assertEquals(
new LongValue(1)
, selectItem.getExpression());
Table table = (Table) select.getFromItem();
Assertions.assertEquals("dual", table.getName());
EqualsTo equalsTo = (EqualsTo) select.getWhere();
Column a = (Column) equalsTo.getLeftExpression();
Column b = (Column) equalsTo.getRightExpression();
Assertions.assertEquals("a", a.getColumnName());
Assertions.assertEquals("b", b.getColumnName());
For guidance with the API, use `JSQLFormatter <http://jsqlformatter.manticore-projects.com>`_ to visualize the Traversable Tree of Java Objects:
.. raw:: html
<div class="highlight">
<pre>
SQL Text
└─Statements: net.sf.jsqlparser.statement.select.Select
├─selectItems -> Collection<SelectItem>
│ └─LongValue: 1
├─Table: dual
└─where: net.sf.jsqlparser.expression.operators.relational.EqualsTo
├─Column: a
└─Column: b
</pre>
</div>
Error Handling
==============================
There are two features for handling errors
- ``parser.withErrorRecovery(true)`` will continue to the next statement separator and return an empty statement.
- ``parser.withUnsupportedStatements(true)`` will return an instance of the `UnsupportedStatement` class, although the first statement **must** be a regular statement
.. code-block:: java
:caption: Error Recovery
CCJSqlParser parser = new CCJSqlParser(
"select * from mytable; select from; select * from mytable2" );
Statements statements = parser.withErrorRecovery().Statements();
// 3 statements, the failing one set to NULL
assertEquals(3, statements.size());
assertNull(statements.get(1));
// errors are recorded
assertEquals(1, parser.getParseErrors().size());
.. code-block:: java
:caption: Unsupported Statement
Statements statements = CCJSqlParserUtil.parseStatements(
"select * from mytable; select from; select * from mytable2; select 4;"
, parser -> parser.withUnsupportedStatements() );
// 4 statements with one Unsupported Statement holding the content
assertEquals(4, statements.size());
assertInstanceOf(UnsupportedStatement.class, statements.get(1));
assertEquals("select from", statements.get(1).toString());
// no errors records, because a statement has been returned
assertEquals(0, parser.getParseErrors().size());
Use the Visitor Patterns
==============================
Traverse the Java Object Tree using the Visitor Patterns:
.. code-block:: java
// Define an Expression Visitor reacting on any Expression
// Overwrite the visit() methods for each Expression Class
ExpressionVisitorAdapter<Void> expressionVisitorAdapter = new ExpressionVisitorAdapter<>() {
public <S> Void visit(EqualsTo equalsTo, S context) {
equalsTo.getLeftExpression().accept(this, context);
equalsTo.getRightExpression().accept(this, context);
return null;
}
public <S> Void visit(Column column, S context) {
System.out.println("Found a Column " + column.getColumnName());
return null;
}
};
// Define a Select Visitor reacting on a Plain Select invoking the Expression Visitor on the Where Clause
SelectVisitorAdapter<Void> selectVisitorAdapter = new SelectVisitorAdapter<>() {
@Override
public <S> Void visit(PlainSelect plainSelect, S context) {
return plainSelect.getWhere().accept(expressionVisitorAdapter, context);
}
};
// Define a Statement Visitor for dispatching the Statements
StatementVisitorAdapter<Void> statementVisitor = new StatementVisitorAdapter<>() {
public <S> Void visit(Select select, S context) {
return select.getSelectBody().accept(selectVisitorAdapter, context);
}
};
String sqlStr="select 1 from dual where a=b";
Statement stmt = CCJSqlParserUtil.parse(sqlStr);
// Invoke the Statement Visitor without a context
stmt.accept(statementVisitor, null);
Find Table Names
==============================
The class ``net.sf.jsqlparser.util.TablesNamesFinder`` can be used to return all Table Names from a Query or an Expression.
.. code-block:: java
// find in Statements
String sqlStr = "select * from A left join B on A.id=B.id and A.age = (select age from C)";
Set<String> tableNames = TablesNamesFinder.findTables(sqlStr);
assertThat( tableNames ).containsExactlyInAnyOrder("A", "B", "C");
// find in Expressions
String exprStr = "A.id=B.id and A.age = (select age from C)";
tableNames = TablesNamesFinder.findTablesInExpression(exprStr);
assertThat( tableNames ).containsExactlyInAnyOrder("A", "B", "C");
Build a SQL Statement
==============================
Build any SQL Statement from Java Code using a fluent API:
.. code-block:: java
String expectedSQLStr = "SELECT 1 FROM dual t WHERE a = b";
// Step 1: generate the Java Object Hierarchy for
Table table = new Table().withName("dual").withAlias(new Alias("t", false));
Column columnA = new Column().withColumnName("a");
Column columnB = new Column().withColumnName("b");
Expression whereExpression =
new EqualsTo().withLeftExpression(columnA).withRightExpression(columnB);
PlainSelect select = new PlainSelect().addSelectItem(new LongValue(1))
.withFromItem(table).withWhere(whereExpression);
// Step 2a: Print into a SQL Statement
Assertions.assertEquals(expectedSQLStr, select.toString());
// Step 2b: De-Parse into a SQL Statement
StringBuilder builder = new StringBuilder();
StatementDeParser deParser = new StatementDeParser(builder);
deParser.visit(select);
Assertions.assertEquals(expectedSQLStr, builder.toString());
Define the Parser Features
==============================
JSQLParser interprets Squared Brackets ``[..]`` as Arrays, which does not work with MS SQL Server and T-SQL. Please use the Parser Features to instruct JSQLParser to read Squared Brackets as Quotes instead.
JSQLParser allows for standard compliant Single Quote ``'..`` Escaping. Additional Back-slash ``\..`` Escaping needs to be activated by setting the ``BackSlashEscapeCharacter`` parser feature.
Additionally there are Features to control the Parser's effort at the cost of the performance.
.. code-block:: java
String sqlStr="select 1 from [sample_table] where [a]=[b]";
// T-SQL Square Bracket Quotation
Statement stmt = CCJSqlParserUtil.parse(
sqlStr
, parser -> parser
.withSquareBracketQuotation(true)
);
// Set Parser Timeout to 6000 ms
Statement stmt1 = CCJSqlParserUtil.parse(
sqlStr
, parser -> parser
.withSquareBracketQuotation(true)
.withTimeOut(6000)
);
// Allow Complex Parsing (which allows nested Expressions, but is much slower)
Statement stmt2 = CCJSqlParserUtil.parse(
sqlStr
, parser -> parser
.withSquareBracketQuotation(true)
.withAllowComplexParsing(true)
.withTimeOut(6000)
);
// Allow Back-slash escaping
sqlStr="SELECT ('\\'Clark\\'', 'Kent')";
Statement stmt2 = CCJSqlParserUtil.parse(
sqlStr
, parser -> parser
.withBackslashEscapeCharacter(true)
);