Harbor format: every task as tasks/<task_id>/

#6
by ybelkada HF Staff - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
Files changed (50) hide show
  1. .gitattributes +305 -0
  2. README.md +16 -0
  3. licenses/access-review-LICENSE.txt +179 -0
  4. licenses/cedar-integration-tests-LICENSE +175 -0
  5. licenses/cedar-integration-tests-NOTICE +1 -0
  6. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/Dockerfile +2 -0
  7. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/.gitignore +1 -0
  8. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/.travis.yml +30 -0
  9. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/LICENSE +23 -0
  10. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/README.md +142 -0
  11. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/case.go +128 -0
  12. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/delete.go +191 -0
  13. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/delete_ctx.go +69 -0
  14. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/expr.go +419 -0
  15. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/go.mod +11 -0
  16. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/go.sum +10 -0
  17. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/insert.go +298 -0
  18. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/insert_ctx.go +69 -0
  19. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/doc.go +2 -0
  20. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/go.mod +14 -0
  21. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/go.sum +34 -0
  22. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/part.go +63 -0
  23. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/placeholder.go +114 -0
  24. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/row.go +22 -0
  25. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/select.go +403 -0
  26. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/select_ctx.go +69 -0
  27. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/squirrel.go +183 -0
  28. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/squirrel_ctx.go +93 -0
  29. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/statement.go +104 -0
  30. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher.go +121 -0
  31. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher_ctx.go +86 -0
  32. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher_noctx.go +21 -0
  33. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/update.go +288 -0
  34. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/update_ctx.go +69 -0
  35. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/where.go +30 -0
  36. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/instruction.md +46 -0
  37. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/provenance.json +385 -0
  38. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/solution/solve.sh +12 -0
  39. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/task.toml +11 -0
  40. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/case_test.go +150 -0
  41. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/delete_ctx_test.go +41 -0
  42. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/delete_test.go +81 -0
  43. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/expr_test.go +464 -0
  44. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/insert_ctx_test.go +41 -0
  45. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/insert_test.go +112 -0
  46. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/integration/integration_test.go +135 -0
  47. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/placeholder_test.go +67 -0
  48. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/row_test.go +34 -0
  49. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/select_ctx_test.go +41 -0
  50. tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/select_test.go +463 -0
.gitattributes CHANGED
@@ -59,3 +59,308 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
  data/tasks.jsonl filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
  data/tasks.jsonl filter=lfs diff=lfs merge=lfs -text
62
+ tasks/tasksmith-35d8641e8647/tests/source/docs/_static/social[[:space:]]card.afdesign filter=lfs diff=lfs merge=lfs -text
63
+ tasks/tasksmith-4ca6d2396445/tests/source/docs/_static/social[[:space:]]card.afdesign filter=lfs diff=lfs merge=lfs -text
64
+ tasks/tasksmith-0ba04a338dbb/tests/source/tests/data/doc/concatenated.html filter=lfs diff=lfs merge=lfs -text
65
+ tasks/tasksmith-0ba04a338dbb/tests/source/tests/data/doc/concatenated.json filter=lfs diff=lfs merge=lfs -text
66
+ tasks/tasksmith-0ba04a338dbb/tests/source/tests/data/doc/doclang_archive/load/two_pages.dclx filter=lfs diff=lfs merge=lfs -text
67
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/act-props.pptm filter=lfs diff=lfs merge=lfs -text
68
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
69
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-axis-props.pptx filter=lfs diff=lfs merge=lfs -text
70
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-category-access.pptx filter=lfs diff=lfs merge=lfs -text
71
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-chart-props.pptx filter=lfs diff=lfs merge=lfs -text
72
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-chart-type.pptx filter=lfs diff=lfs merge=lfs -text
73
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-datalabels.pptx filter=lfs diff=lfs merge=lfs -text
74
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-legend-props.pptx filter=lfs diff=lfs merge=lfs -text
75
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-legend.pptx filter=lfs diff=lfs merge=lfs -text
76
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-plot-props.pptx filter=lfs diff=lfs merge=lfs -text
77
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-point-access.pptx filter=lfs diff=lfs merge=lfs -text
78
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-point-props.pptx filter=lfs diff=lfs merge=lfs -text
79
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-replace-data.pptx filter=lfs diff=lfs merge=lfs -text
80
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-series.pptx filter=lfs diff=lfs merge=lfs -text
81
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/cht-ticklabels-props.pptx filter=lfs diff=lfs merge=lfs -text
82
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/dml-fill.pptx filter=lfs diff=lfs merge=lfs -text
83
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/ph-populated-placeholders.pptx filter=lfs diff=lfs merge=lfs -text
84
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/shp-access-ole-object.pptx filter=lfs diff=lfs merge=lfs -text
85
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/shp-movie-props.pptx filter=lfs diff=lfs merge=lfs -text
86
+ tasks/tasksmith-74f059424102/environment/source/features/steps/test_files/shp-shapes.pptx filter=lfs diff=lfs merge=lfs -text
87
+ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-1/ISO-IEC-29500-1.pdf filter=lfs diff=lfs merge=lfs -text
88
+ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-2/ISO-IEC-29500-2.pdf filter=lfs diff=lfs merge=lfs -text
89
+ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-3/ISO-IEC-29500-3.pdf filter=lfs diff=lfs merge=lfs -text
90
+ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-4/ISO-IEC-29500-4.pdf filter=lfs diff=lfs merge=lfs -text
91
+ tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
92
+ tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
93
+ tasks/tasksmith-74f059424102/environment/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
94
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/act-props.pptm filter=lfs diff=lfs merge=lfs -text
95
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
96
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-axis-props.pptx filter=lfs diff=lfs merge=lfs -text
97
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-category-access.pptx filter=lfs diff=lfs merge=lfs -text
98
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-chart-props.pptx filter=lfs diff=lfs merge=lfs -text
99
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-chart-type.pptx filter=lfs diff=lfs merge=lfs -text
100
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-datalabels.pptx filter=lfs diff=lfs merge=lfs -text
101
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-legend-props.pptx filter=lfs diff=lfs merge=lfs -text
102
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-legend.pptx filter=lfs diff=lfs merge=lfs -text
103
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-plot-props.pptx filter=lfs diff=lfs merge=lfs -text
104
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-point-access.pptx filter=lfs diff=lfs merge=lfs -text
105
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-point-props.pptx filter=lfs diff=lfs merge=lfs -text
106
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-replace-data.pptx filter=lfs diff=lfs merge=lfs -text
107
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-series.pptx filter=lfs diff=lfs merge=lfs -text
108
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-ticklabels-props.pptx filter=lfs diff=lfs merge=lfs -text
109
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/dml-fill.pptx filter=lfs diff=lfs merge=lfs -text
110
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/ph-populated-placeholders.pptx filter=lfs diff=lfs merge=lfs -text
111
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-access-ole-object.pptx filter=lfs diff=lfs merge=lfs -text
112
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-movie-props.pptx filter=lfs diff=lfs merge=lfs -text
113
+ tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-shapes.pptx filter=lfs diff=lfs merge=lfs -text
114
+ tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-1/ISO-IEC-29500-1.pdf filter=lfs diff=lfs merge=lfs -text
115
+ tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-2/ISO-IEC-29500-2.pdf filter=lfs diff=lfs merge=lfs -text
116
+ tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-3/ISO-IEC-29500-3.pdf filter=lfs diff=lfs merge=lfs -text
117
+ tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-4/ISO-IEC-29500-4.pdf filter=lfs diff=lfs merge=lfs -text
118
+ tasks/tasksmith-74f059424102/tests/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
119
+ tasks/tasksmith-74f059424102/tests/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
120
+ tasks/tasksmith-74f059424102/tests/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
121
+ tasks/tasksmith-87860368c397/environment/source/examples/pdfs/ca-warn-report.pdf filter=lfs diff=lfs merge=lfs -text
122
+ tasks/tasksmith-87860368c397/tests/source/examples/pdfs/ca-warn-report.pdf filter=lfs diff=lfs merge=lfs -text
123
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/WARN-Report-for-7-1-2015-to-03-25-2016.pdf filter=lfs diff=lfs merge=lfs -text
124
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/annotations-rotated-180.pdf filter=lfs diff=lfs merge=lfs -text
125
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/annotations-rotated-270.pdf filter=lfs diff=lfs merge=lfs -text
126
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/annotations-rotated-90.pdf filter=lfs diff=lfs merge=lfs -text
127
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/annotations.pdf filter=lfs diff=lfs merge=lfs -text
128
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/chelsea_pdta.pdf filter=lfs diff=lfs merge=lfs -text
129
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/federal-register-2020-17221.pdf filter=lfs diff=lfs merge=lfs -text
130
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-1147-example.pdf filter=lfs diff=lfs merge=lfs -text
131
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-13-151201DSP-Fond-581-90D.pdf filter=lfs diff=lfs merge=lfs -text
132
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-192-example.pdf filter=lfs diff=lfs merge=lfs -text
133
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-203-decimalize.pdf filter=lfs diff=lfs merge=lfs -text
134
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-316-example.pdf filter=lfs diff=lfs merge=lfs -text
135
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-336-example.pdf filter=lfs diff=lfs merge=lfs -text
136
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-461-example.pdf filter=lfs diff=lfs merge=lfs -text
137
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-53-example.pdf filter=lfs diff=lfs merge=lfs -text
138
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-598-example.pdf filter=lfs diff=lfs merge=lfs -text
139
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-67-example.pdf filter=lfs diff=lfs merge=lfs -text
140
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-71-duplicate-chars-2.pdf filter=lfs diff=lfs merge=lfs -text
141
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-842-example.pdf filter=lfs diff=lfs merge=lfs -text
142
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-912.pdf filter=lfs diff=lfs merge=lfs -text
143
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/issue-982-example.pdf filter=lfs diff=lfs merge=lfs -text
144
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/pdffill-demo.pdf filter=lfs diff=lfs merge=lfs -text
145
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/pr-136-example.pdf filter=lfs diff=lfs merge=lfs -text
146
+ tasks/tasksmith-87860368c397/tests/source/tests/pdfs/table-curves-example.pdf filter=lfs diff=lfs merge=lfs -text
147
+ tasks/tasksmith-ca08ab4caec6/environment/source/etc/NYSE-Historical-Closings.pdf filter=lfs diff=lfs merge=lfs -text
148
+ tasks/tasksmith-ca08ab4caec6/tests/source/etc/NYSE-Historical-Closings.pdf filter=lfs diff=lfs merge=lfs -text
149
+ tasks/cuad-dd-abilityinc-06-15-2020-ex-4-25-services-a-8fed5c12/environment/inputs/ABILITYINC_06_15_2020-EX-4.25-SERVICES_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
150
+ tasks/cuad-dd-aspirityholdingsllc-05-07-2012-ex-10-6-o-bd8fe2fb/environment/inputs/ASPIRITYHOLDINGSLLC_05_07_2012-EX-10.6-OUTSOURCING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
151
+ tasks/cuad-dd-bellicumpharmaceuticals-inc-05-07-2019-e-ec75c76a-v2/environment/inputs/BELLICUMPHARMACEUTICALS_INC_05_07_2019-EX-10.1-Supply_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
152
+ tasks/cuad-dd-bellringbrandsinc-20190920-s-1-ex-10-12--66989f1d/environment/inputs/BellringBrandsInc_20190920_S-1_EX-10.12_11817081_EX-10.12_Manufacturing_Agreement1.pdf filter=lfs diff=lfs merge=lfs -text
153
+ tasks/cuad-dd-biofronteraag-04-29-2019-ex-4-17-supply--b6ba1de7/environment/inputs/BIOFRONTERAAG_04_29_2019-EX-4.17-SUPPLY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
154
+ tasks/cuad-dd-bluehillsbancorp-inc-05-20-2014-ex-1-1-a-3b4f7a9d/environment/inputs/BLUEHILLSBANCORP_INC_05_20_2014-EX-1.1-AGENCY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
155
+ tasks/cuad-dd-bnlfinancialcorp-03-30-2007-ex-10-8-outs-ba8d11be-v2/environment/inputs/BNLFINANCIALCORP_03_30_2007-EX-10.8-OUTSOURCING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
156
+ tasks/cuad-dd-cardlyticsinc-20180112-s-1-ex-10-16-1100-f98f4db5/environment/inputs/CardlyticsInc_20180112_S-1_EX-10.16_11002987_EX-10.16_Maintenance_Agreement1.pdf filter=lfs diff=lfs merge=lfs -text
157
+ tasks/cuad-dd-ccrealestateincomefundadv-20181205-pos-8-d9e98ce6-v2/environment/inputs/CcRealEstateIncomeFundadv_20181205_POS_8C_EX-99._H_3__11447739_EX-99._H_3__Marketing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
158
+ tasks/cuad-dd-changepointcorp-03-08-2000-ex-10-6-licen-87b3eaf0/environment/inputs/CHANGEPOINTCORP_03_08_2000-EX-10.6-LICENSE_AND_HOSTING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
159
+ tasks/cuad-dd-cybergyholdingsinc-20140520-10-q-ex-10-2-083c6aa1/environment/inputs/CybergyHoldingsInc_20140520_10-Q_EX-10.27_8605784_EX-10.27_Affiliate_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
160
+ tasks/cuad-dd-cytodyninc-20200109-10-q-ex-10-5-1194163-6fba2c7c-v2/environment/inputs/CytodynInc_20200109_10-Q_EX-10.5_11941634_EX-10.5_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
161
+ tasks/cuad-dd-diversinetcorp-03-01-2012-ex-4-reseller--ca47fd8c/environment/inputs/DIVERSINETCORP_03_01_2012-EX-4-RESELLER_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
162
+ tasks/cuad-dd-ecosciencesolutionsinc-20171117-8-k-ex-1-2ff03f1b-v3/environment/inputs/EcoScienceSolutionsInc_20171117_8-K_EX-10.1_10956472_EX-10.1_Endorsement_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
163
+ tasks/cuad-dd-elandiainternationalinc-04-25-2007-ex-10-8f8ca97f-v3/environment/inputs/ELANDIAINTERNATIONALINC_04_25_2007-EX-10.21-Outsourcing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
164
+ tasks/cuad-dd-elfbeauty-inc-07-02-2020-ex-10-1-coopera-4857c747/environment/inputs/ELFBEAUTY_INC_07_02_2020-EX-10.1-COOPERATION_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
165
+ tasks/cuad-dd-euromediaholdingscorp-20070215-10sb12g-e-28af50c4/environment/inputs/EuromediaHoldingsCorp_20070215_10SB12G_EX-10.B_01__525118_EX-10.B_01__Content_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
166
+ tasks/cuad-dd-fibrogeninc-10-01-2014-ex-10-11-collabor-10a96028/environment/inputs/FIBROGENINC_10_01_2014-EX-10.11-COLLABORATION_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
167
+ tasks/cuad-dd-ftenetworks-inc-02-18-2016-ex-99-4-strat-3263edde/environment/inputs/FTENETWORKS_INC_02_18_2016-EX-99.4-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
168
+ tasks/cuad-dd-fulucaiproductionsltd-20131223-10-q-ex-1-f4941a31/environment/inputs/FulucaiProductionsLtd_20131223_10-Q_EX-10.9_8368347_EX-10.9_Content_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
169
+ tasks/cuad-dd-globaltechnologiesgroupinc-20050928-10ks-8321c3b8/environment/inputs/GlobalTechnologiesGroupInc_20050928_10KSB_EX-10.9_4148808_EX-10.9_Content_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
170
+ tasks/cuad-dd-glumobileinc-20070319-s-1a-ex-10-09-4366-e73220ff/environment/inputs/GluMobileInc_20070319_S-1A_EX-10.09_436630_EX-10.09_Content_License_Agreement1.pdf filter=lfs diff=lfs merge=lfs -text
171
+ tasks/cuad-dd-goldresourcecorp-12-11-2008-ex-10-1-stra-56ce5e27-v3/environment/inputs/GOLDRESOURCECORP_12_11_2008-EX-10.1-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
172
+ tasks/cuad-dd-gpaqacquisitionholdingsinc-20200123-s-4a-24fcbe48/environment/inputs/GpaqAcquisitionHoldingsInc_20200123_S-4A_EX-10.6_11951677_EX-10.6_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
173
+ tasks/cuad-dd-gridironbionutrients-inc-02-05-2020-ex-1-5a68fb60-v2/environment/inputs/GRIDIRONBIONUTRIENTS_INC_02_05_2020-EX-10.3-SUPPLY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
174
+ tasks/cuad-dd-healthgatedatacorp-11-24-1999-ex-10-1-ho-c456bfc3/environment/inputs/HEALTHGATEDATACORP_11_24_1999-EX-10.1-HOSTING_AND_MANAGEMENT_AGREEMENT_1.pdf filter=lfs diff=lfs merge=lfs -text
175
+ tasks/cuad-dd-ibioinc-20200313-8-k-ex-10-1-12052678-ex-5ded7f3c-v2/environment/inputs/IbioInc_20200313_8-K_EX-10.1_12052678_EX-10.1_Development_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
176
+ tasks/cuad-dd-ideanomicsinc-20160330-10-k-ex-10-26-951-34feb55f/environment/inputs/IdeanomicsInc_20160330_10-K_EX-10.26_9512211_EX-10.26_Content_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
177
+ tasks/cuad-dd-idreamskytechnologyltd-07-03-2014-ex-10--92e3e5c0-v2/environment/inputs/IDREAMSKYTECHNOLOGYLTD_07_03_2014-EX-10.39-Cooperation_Agreement_on_Mobile_Game_Business.pdf filter=lfs diff=lfs merge=lfs -text
178
+ tasks/cuad-dd-igenebiotechnologyinc-05-13-2003-ex-1-jo-71fbfebb-v2/environment/inputs/IGENEBIOTECHNOLOGYINC_05_13_2003-EX-1-JOINT_VENTURE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
179
+ tasks/cuad-dd-iminecorp-20180725-s-1-ex-10-5-11275970--06080324-v2/environment/inputs/ImineCorp_20180725_S-1_EX-10.5_11275970_EX-10.5_Distributor_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
180
+ tasks/cuad-dd-impressecorp-20000322-s-1a-ex-10-11-5199-95c2d66c/environment/inputs/ImpresseCorp_20000322_S-1A_EX-10.11_5199234_EX-10.11_Co-Branding_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
181
+ tasks/cuad-dd-internationalfastfoodcorp-04-04-1997-ex--4f3232be-v3/environment/inputs/INTERNATIONALFASTFOODCORP_04_04_1997-EX-99-FRANCHISE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
182
+ tasks/cuad-dd-intersectent-inc-05-11-2020-ex-10-1-supp-cb82a343-v2/environment/inputs/INTERSECTENT_INC_05_11_2020-EX-10.1-SUPPLY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
183
+ tasks/cuad-dd-iovancebiotherapeutics-inc-08-03-2017-ex-5067cd14/environment/inputs/IOVANCEBIOTHERAPEUTICS_INC_08_03_2017-EX-10.1-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
184
+ tasks/cuad-dd-jingweiinternationalltd-10-04-2007-ex-10-6361913d/environment/inputs/JINGWEIINTERNATIONALLTD_10_04_2007-EX-10.7-INTELLECTUAL_PROPERTY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
185
+ tasks/cuad-dd-lejuholdingsltd-20140121-drs-on-f-1-ex--daa077cf/environment/inputs/LejuHoldingsLtd_20140121_DRS_on_F-1__EX-10.26_8473102_EX-10.26_Content_License_Agreement1.pdf filter=lfs diff=lfs merge=lfs -text
186
+ tasks/cuad-dd-loyaltypointinc-11-16-2004-ex-10-2-resel-96103a19/environment/inputs/LOYALTYPOINTINC_11_16_2004-EX-10.2-RESELLER_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
187
+ tasks/cuad-dd-magenta-therapeutics-inc---master-devel-4b001d95/environment/inputs/Magenta_Therapeutics_Inc._-_Master_Development_and_Manufacturing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
188
+ tasks/cuad-dd-ofgbancorp-03-28-2007-ex-10-23-outsourci-6d2c44f4/environment/inputs/OFGBANCORP_03_28_2007-EX-10.23-OUTSOURCING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
189
+ tasks/cuad-dd-oldapiwind-downltd-01-08-2016-ex-1-3-age-36744ba9/environment/inputs/OLDAPIWIND-DOWNLTD_01_08_2016-EX-1.3-AGENCY_AGREEMENT1.pdf filter=lfs diff=lfs merge=lfs -text
190
+ tasks/cuad-dd-paratekpharmaceuticalsinc-20170505-10-ka-9136ba4e/environment/inputs/ParatekPharmaceuticalsInc_20170505_10-KA_EX-10.29_10323872_EX-10.29_Outsourcing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
191
+ tasks/cuad-dd-pelicandeliversinc-20200211-s-1-ex-10-3--5a88247f/environment/inputs/PelicanDeliversInc_20200211_S-1_EX-10.3_11975895_EX-10.3_Development_Agreement2.pdf filter=lfs diff=lfs merge=lfs -text
192
+ tasks/cuad-dd-premierbiomedicalinc-05-14-2020-ex-10-2--a6870dfb/environment/inputs/PREMIERBIOMEDICALINC_05_14_2020-EX-10.2-INTELLECTUAL_PROPERTY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
193
+ tasks/cuad-dd-rareelementresourcesltd-20171019-sc-13d--1ce0b720/environment/inputs/RareElementResourcesLtd_20171019_SC_13D_EX-99.4_10897534_EX-99.4_Intellectual_Property_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
194
+ tasks/cuad-dd-reganholdingcorp-03-31-2008-ex-10-licens-68a0b439/environment/inputs/REGANHOLDINGCORP_03_31_2008-EX-10-LICENSE_AND_HOSTING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
195
+ tasks/cuad-dd-reynoldsconsumerproductsinc-20200121-s-1-7fd06763/environment/inputs/ReynoldsConsumerProductsInc_20200121_S-1A_EX-10.22_11948918_EX-10.22_Service_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
196
+ tasks/cuad-dd-rubiosrestaurantsinc-03-31-2008-ex-10-75-04fcb1ea-v2/environment/inputs/RUBIOSRESTAURANTSINC_03_31_2008-EX-10.75-SPONSORSHIP_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
197
+ tasks/cuad-dd-scoutcaminc-05-12-2020-ex-10-22-services-2af3cb66/environment/inputs/SCOUTCAMINC_05_12_2020-EX-10.22-SERVICES_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
198
+ tasks/cuad-dd-spienergyco-ltd-03-09-2011-ex-99-5-opera-c468dc5d/environment/inputs/SPIENERGYCO_LTD_03_09_2011-EX-99.5-OPERATIONS_AND_MAINTENANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
199
+ tasks/cuad-dd-stampscominc-20001114-10-q-ex-10-47-2631-979f273c-v2/environment/inputs/StampscomInc_20001114_10-Q_EX-10.47_2631630_EX-10.47_Co-Branding_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
200
+ tasks/cuad-dd-talcottresolutionlifeinsuranceco-separat-b99655ad/environment/inputs/TALCOTTRESOLUTIONLIFEINSURANCECO-SEPARATEACCOUNTTWELVE_04_30_2020-EX-99.8_L_-SERVICE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
201
+ tasks/cuad-dd-usioinc-20040428-sb-2-ex-10-11-1723988-e-3ac7c718-v3/environment/inputs/UsioInc_20040428_SB-2_EX-10.11_1723988_EX-10.11_Affiliate_Agreement_2.pdf filter=lfs diff=lfs merge=lfs -text
202
+ tasks/cuad-dd-vertexenergyinc-08-14-2014-ex-10-24-oper-6ee46db2/environment/inputs/VERTEXENERGYINC_08_14_2014-EX-10.24-OPERATION_AND_MAINTENANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
203
+ tasks/cuad-dd-violinmemoryinc-12-12-2012-ex-10-14-spon-d8b8bbba/environment/inputs/VIOLINMEMORYINC_12_12_2012-EX-10.14-SPONSORSHIP_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
204
+ tasks/cuad-dd-vitaminshoppecominc-09-13-1999-ex-10-26--ee13ce97/environment/inputs/VITAMINSHOPPECOMINC_09_13_1999-EX-10.26-SPONSORSHIP_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
205
+ tasks/cuad-dd-webmdhealthcorp-20050908-s-1a-ex-10-7-10-1a2dc974/environment/inputs/WebmdHealthCorp_20050908_S-1A_EX-10.7_1027007_EX-10.7_Content_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
206
+ tasks/cuad-dd-whitesmoke-inc-11-08-2011-ex-10-26-promo-074ca454-v2/environment/inputs/WHITESMOKE_INC_11_08_2011-EX-10.26-PROMOTION_AND_DISTRIBUTION_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
207
+ tasks/cuad-dd-xpresspagroupinc-20190401-10-k-ex-10-28--1ddc3af4/environment/inputs/XpresspaGroupInc_20190401_10-K_EX-10.28_11599457_EX-10.28_Marketing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
208
+ tasks/cuad-dd-zebratechnologiescorp-04-16-2014-ex-10-1-ca05f105/environment/inputs/ZEBRATECHNOLOGIESCORP_04_16_2014-EX-10.1-INTELLECTUAL_PROPERTY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
209
+ tasks/cuad-room-064316a23534/environment/inputs/contracts/CerenceInc_20191002_8-K_EX-10.4_11827494_EX-10.4_Intellectual_Property_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
210
+ tasks/cuad-room-064316a23534/environment/inputs/contracts/HUBEIMINKANGPHARMACEUTICALLTD_09_19_2006-EX-10.1-OUTSOURCING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
211
+ tasks/cuad-room-064316a23534/environment/inputs/contracts/LECLANCHE_S.A._-_JOINT_DEVELOPMENT_AND_MARKETING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
212
+ tasks/cuad-room-064316a23534/environment/inputs/contracts/NEXSTARFINANCEHOLDINGSINC_03_27_2002-EX-10.26-OUTSOURCING_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
213
+ tasks/cuad-room-1da66b3aec27/environment/inputs/contracts/KUBIENT_INC_07_02_2020-EX-10.14-MASTER_SERVICES_AGREEMENT_Part1.pdf filter=lfs diff=lfs merge=lfs -text
214
+ tasks/cuad-room-1da66b3aec27/environment/inputs/contracts/KitovPharmaLtd_20190326_20-F_EX-4.15_11584449_EX-4.15_Manufacturing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
215
+ tasks/cuad-room-1da66b3aec27/environment/inputs/contracts/OAKTREECAPITALGROUP_LLC_03_02_2020-EX-10.8-Services_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
216
+ tasks/cuad-room-1da66b3aec27/environment/inputs/contracts/VirtuosoSurgicalInc_20191227_1-A_EX1A-6_MAT_CTRCT_11933379_EX1A-6_MAT_CTRCT_License_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
217
+ tasks/cuad-room-3fff017ca65e/environment/inputs/contracts/BravatekSolutionsInc_20170418_8-K_EX-10.1_10205739_EX-10.1_Reseller_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
218
+ tasks/cuad-room-3fff017ca65e/environment/inputs/contracts/PapaJohnsInternationalInc_20190617_8-K_EX-10.1_11707365_EX-10.1_Endorsement_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
219
+ tasks/cuad-room-3fff017ca65e/environment/inputs/contracts/SmartRxSystemsInc_20180914_1-A_EX1A-6_MAT_CTRCT_11351705_EX1A-6_MAT_CTRCT_Distributor_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
220
+ tasks/cuad-room-4ad85da1eda2-v2/environment/inputs/contracts/ALLISONTRANSMISSIONHOLDINGSINC_12_15_2014-EX-99.1-COOPERATION_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
221
+ tasks/cuad-room-4ad85da1eda2-v2/environment/inputs/contracts/PrudentialBancorpInc_20170606_8-K_EX-10.4_10474434_EX-10.4_Endorsement_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
222
+ tasks/cuad-room-4ad85da1eda2-v2/environment/inputs/contracts/StaarSurgicalCompany_20180801_10-Q_EX-10.37_11289449_EX-10.37_Distributor_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
223
+ tasks/cuad-room-680e05c7226a/environment/inputs/contracts/GIGGLESN_HUGS_INC_06_23_2016-EX-10.2-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
224
+ tasks/cuad-room-680e05c7226a/environment/inputs/contracts/SUMMAFOURINC_06_19_1998-EX-10.3-SOFTWARE_LICENSE_AND_MAINTENANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
225
+ tasks/cuad-room-784f4abbce9f-v2/environment/inputs/contracts/QuantumGroupIncFl_20090120_8-K_EX-99.2_3672910_EX-99.2_Hosting_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
226
+ tasks/cuad-room-784f4abbce9f-v2/environment/inputs/contracts/SimplicityEsportsGamingCompany_20181130_8-K_EX-10.1_11444071_EX-10.1_Franchise_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
227
+ tasks/cuad-room-784f4abbce9f-v2/environment/inputs/contracts/SoupmanInc_20150814_8-K_EX-10.1_9230148_EX-10.1_Franchise_Agreement3.pdf filter=lfs diff=lfs merge=lfs -text
228
+ tasks/cuad-room-b5921146a70e/environment/inputs/contracts/MIDDLEBROOKPHARMACEUTICALS_INC_03_18_2010-EX-10.1-PROMOTION_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
229
+ tasks/cuad-room-b5921146a70e/environment/inputs/contracts/ScansourceInc_20190822_10-K_EX-10.38_11793958_EX-10.38_Distributor_Agreement1.pdf filter=lfs diff=lfs merge=lfs -text
230
+ tasks/cuad-room-bb02e3b18b4c-v2/environment/inputs/contracts/DigitalCinemaDestinationsCorp_20111220_S-1_EX-10.10_7346719_EX-10.10_Affiliate_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
231
+ tasks/cuad-room-bb02e3b18b4c-v2/environment/inputs/contracts/MPLXLP_06_17_2015-EX-10.1-TRANSPORTATION_SERVICES_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
232
+ tasks/cuad-room-bb02e3b18b4c-v2/environment/inputs/contracts/THERAVANCEBIOPHARMA_INC_05_08_2020-EX-10.2-SERVICE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
233
+ tasks/cuad-room-c79d7903160a-v2/environment/inputs/contracts/InmodeLtd_20190729_F-1A_EX-10.9_11743243_EX-10.9_Manufacturing_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
234
+ tasks/cuad-room-c79d7903160a-v2/environment/inputs/contracts/NlsPharmaceuticsLtd_20200228_F-1_EX-10.14_12029046_EX-10.14_Development_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
235
+ tasks/cuad-room-c79d7903160a-v2/environment/inputs/contracts/REWALKROBOTICSLTD_07_10_2014-EX-10.2-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
236
+ tasks/cuad-room-d661b897721b/environment/inputs/contracts/EmeraldHealthBioceuticalsInc_20200218_1-A_EX1A-6_MAT_CTRCT_11987205_EX1A-6_MAT_CTRCT_Development_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
237
+ tasks/cuad-room-d661b897721b/environment/inputs/contracts/VARIABLESEPARATEACCOUNT_04_30_2014-EX-13.C-UNCONDITIONAL_CAPITAL_MAINTENANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
238
+ tasks/cuad-room-d661b897721b/environment/inputs/contracts/VAXCYTE_INC_05_22_2020-EX-10.19-SUPPLY_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
239
+ tasks/cuad-room-f1105c186b36-v2/environment/inputs/contracts/ENERGOUSCORP_03_16_2017-EX-10.24-STRATEGIC_ALLIANCE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
240
+ tasks/cuad-room-f1f7c01b4fc9-v2/environment/inputs/contracts/ArcaUsTreasuryFund_20200207_N-2_EX-99.K5_11971930_EX-99.K5_Development_Agreement.pdf filter=lfs diff=lfs merge=lfs -text
241
+ tasks/cuad-room-f1f7c01b4fc9-v2/environment/inputs/contracts/VEONEER_INC_02_21_2020-EX-10.11-JOINT_VENTURE_AGREEMENT.pdf filter=lfs diff=lfs merge=lfs -text
242
+ tasks/market-entry-nc-building-supply/environment/inputs/census/CBSA-EST2025-ALLDATA.pdf filter=lfs diff=lfs merge=lfs -text
243
+ tasks/market-entry-nc-building-supply/environment/inputs/census/cntyasc.pdf filter=lfs diff=lfs merge=lfs -text
244
+ tasks/market-entry-va-therapy/environment/inputs/bea/FIPSModifications.pdf filter=lfs diff=lfs merge=lfs -text
245
+ tasks/market-entry-va-therapy/environment/inputs/census/CC-EST2025-AGESEX.pdf filter=lfs diff=lfs merge=lfs -text
246
+ tasks/maud-contract0-43ba3310-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
247
+ tasks/maud-contract1-58d1e38e-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
248
+ tasks/maud-contract10-6c657615-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
249
+ tasks/maud-contract101-cc900e96-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
250
+ tasks/maud-contract104-9c315350-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
251
+ tasks/maud-contract107-b2d59d05-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
252
+ tasks/maud-contract11-034c401b-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
253
+ tasks/maud-contract11-78c4f8ec-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
254
+ tasks/maud-contract11-959df5c0-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
255
+ tasks/maud-contract11-bec0ec7c-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
256
+ tasks/maud-contract111-1c3236c8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
257
+ tasks/maud-contract111-b99f554f-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
258
+ tasks/maud-contract113-94e17166-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
259
+ tasks/maud-contract114-af7928df-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
260
+ tasks/maud-contract114-d3bad00c-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
261
+ tasks/maud-contract117-e47deca7-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
262
+ tasks/maud-contract117-e7b8600e-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
263
+ tasks/maud-contract118-ac658d89-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
264
+ tasks/maud-contract120-0149bbc8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
265
+ tasks/maud-contract120-10a23d59-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
266
+ tasks/maud-contract120-41f6e05a-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
267
+ tasks/maud-contract120-66ee1b86-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
268
+ tasks/maud-contract121-814493f2-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
269
+ tasks/maud-contract122-beaff7c7-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
270
+ tasks/maud-contract122-ec5e204a-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
271
+ tasks/maud-contract124-4168d70d-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
272
+ tasks/maud-contract124-4eba3413-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
273
+ tasks/maud-contract124-a13c7ec4-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
274
+ tasks/maud-contract124-c28f8404-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
275
+ tasks/maud-contract125-58c67260-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
276
+ tasks/maud-contract125-6157d9ea-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
277
+ tasks/maud-contract127-165b69d9-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
278
+ tasks/maud-contract127-aa06aabd-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
279
+ tasks/maud-contract130-90b63db8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
280
+ tasks/maud-contract130-a3085f18-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
281
+ tasks/maud-contract130-e1018afb-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
282
+ tasks/maud-contract133-8b60a1c8-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
283
+ tasks/maud-contract133-cc49a678-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
284
+ tasks/maud-contract134-29bc9247-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
285
+ tasks/maud-contract134-7c778e89-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
286
+ tasks/maud-contract134-b6c3901b-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
287
+ tasks/maud-contract14-4b5deddf-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
288
+ tasks/maud-contract141-4b4a4674-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
289
+ tasks/maud-contract141-5e048673-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
290
+ tasks/maud-contract143-5264b09c-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
291
+ tasks/maud-contract143-c7d30229-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
292
+ tasks/maud-contract144-26cb2971-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
293
+ tasks/maud-contract145-49595272-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
294
+ tasks/maud-contract145-49d06ba4-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
295
+ tasks/maud-contract145-f498ec72-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
296
+ tasks/maud-contract146-fbc0a17b-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
297
+ tasks/maud-contract147-1a36b461-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
298
+ tasks/maud-contract148-77fcc356-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
299
+ tasks/maud-contract16-17230d15-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
300
+ tasks/maud-contract16-a3779b87-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
301
+ tasks/maud-contract17-7885cdaf-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
302
+ tasks/maud-contract23-76b6054b-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
303
+ tasks/maud-contract28-3c780c7a-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
304
+ tasks/maud-contract28-558ac05f-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
305
+ tasks/maud-contract28-6c1119f8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
306
+ tasks/maud-contract29-0b05c42c-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
307
+ tasks/maud-contract30-979b1f7b-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
308
+ tasks/maud-contract31-0e87721a-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
309
+ tasks/maud-contract31-9430a5b0-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
310
+ tasks/maud-contract32-20506973-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
311
+ tasks/maud-contract32-ffa04025-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
312
+ tasks/maud-contract34-3bac585b-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
313
+ tasks/maud-contract34-d33c4b68-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
314
+ tasks/maud-contract35-35b31950-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
315
+ tasks/maud-contract4-b0491678-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
316
+ tasks/maud-contract40-aa43195c-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
317
+ tasks/maud-contract41-c0bcbbde-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
318
+ tasks/maud-contract41-eed498e0-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
319
+ tasks/maud-contract42-5c88efe8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
320
+ tasks/maud-contract50-0ce3779f-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
321
+ tasks/maud-contract51-6872e901-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
322
+ tasks/maud-contract51-f34bbfd2-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
323
+ tasks/maud-contract52-40d47f88-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
324
+ tasks/maud-contract54-9d9f6627-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
325
+ tasks/maud-contract56-6ac32d59-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
326
+ tasks/maud-contract56-cb46337f-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
327
+ tasks/maud-contract62-349bb8a8-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
328
+ tasks/maud-contract62-4737dfed-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
329
+ tasks/maud-contract63-20579b4b-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
330
+ tasks/maud-contract63-373d2cda-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
331
+ tasks/maud-contract66-69915965-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
332
+ tasks/maud-contract66-7b4f745c-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
333
+ tasks/maud-contract68-cce6b699-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
334
+ tasks/maud-contract68-faa79d07-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
335
+ tasks/maud-contract69-d1291cd4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
336
+ tasks/maud-contract7-6df02afe-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
337
+ tasks/maud-contract71-eabf5adf-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
338
+ tasks/maud-contract75-40b8e5a4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
339
+ tasks/maud-contract79-679cf135-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
340
+ tasks/maud-contract79-91698620-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
341
+ tasks/maud-contract81-b009421d-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
342
+ tasks/maud-contract83-b7aff00f-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
343
+ tasks/maud-contract86-414f088d-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
344
+ tasks/maud-contract86-4419616e-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
345
+ tasks/maud-contract87-0b3852fb-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
346
+ tasks/maud-contract91-0679cb8a-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
347
+ tasks/maud-contract91-1de45597-v4-v2/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
348
+ tasks/maud-contract91-8345f72e-v4/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
349
+ tasks/maud-contract92-c6e3fbd3-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
350
+ tasks/maud-contract92-ec51f913-v5/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
351
+ tasks/maud-contract99-4826c03f-v3/environment/inputs/merger_agreement.docx filter=lfs diff=lfs merge=lfs -text
352
+ tasks/srl-formulas-ea7cd493b478512f-v2/environment/inputs/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
353
+ tasks/srl-formulas-ea7cd493b478512f-v2/solution/files/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
354
+ tasks/srl-formulas-ea7cd493b478512f-v2/tests/target.xlsx filter=lfs diff=lfs merge=lfs -text
355
+ tasks/srl-formulas-f29e0734900d6085/environment/inputs/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
356
+ tasks/srl-formulas-f29e0734900d6085/solution/files/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
357
+ tasks/srl-formulas-f29e0734900d6085/tests/target.xlsx filter=lfs diff=lfs merge=lfs -text
358
+ tasks/srl-general-ea9675c6438c679f/environment/inputs/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
359
+ tasks/srl-general-ea9675c6438c679f/solution/files/workbook.xlsx filter=lfs diff=lfs merge=lfs -text
360
+ tasks/srl-general-ea9675c6438c679f/tests/target.xlsx filter=lfs diff=lfs merge=lfs -text
361
+ tasks/tatdqa-carpenter-technology-cor-b22c2c7d82/environment/inputs/excerpt_1.pdf filter=lfs diff=lfs merge=lfs -text
362
+ tasks/tatdqa-carpenter-technology-cor-b22c2c7d82/environment/inputs/excerpt_2.pdf filter=lfs diff=lfs merge=lfs -text
363
+ tasks/tatdqa-netgear-inc-b42fe3d9ad-v2/environment/inputs/excerpt_1.pdf filter=lfs diff=lfs merge=lfs -text
364
+ tasks/tatdqa-netgear-inc-b42fe3d9ad-v2/environment/inputs/excerpt_2.pdf filter=lfs diff=lfs merge=lfs -text
365
+ tasks/tatdqa-spirent-communications-p-226e7056fc/environment/inputs/excerpt_1.pdf filter=lfs diff=lfs merge=lfs -text
366
+ tasks/tatdqa-spirent-communications-p-226e7056fc/environment/inputs/excerpt_2.pdf filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -223,3 +223,19 @@ This aggregation grants no additional rights to upstream material.
223
  - An earlier write-up: [harness adapters at scale](https://huggingface.co/blog/harness-adapters-at-scale)
224
 
225
  Inventory assembled on 2026-11-27. Counts and historical quality claims describe the selected source artifacts.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  - An earlier write-up: [harness adapters at scale](https://huggingface.co/blog/harness-adapters-at-scale)
224
 
225
  Inventory assembled on 2026-11-27. Counts and historical quality claims describe the selected source artifacts.
226
+
227
+ ## Harbor format
228
+
229
+ Every task is also stored as a [Harbor](https://github.com/harbor-framework/harbor) task folder, `tasks/<task_id>/`
230
+ (`task.toml`, `instruction.md`, `environment/`, `tests/`, `solution/`), so tools that read Harbor datasets can load
231
+ this repository directly:
232
+
233
+ ```sh
234
+ hf download harness-hub/UltraTerminals --repo-type dataset --include "tasks/cedar_authorization-01c2f93d495f34df9bc8/*" --local-dir .
235
+ openenv harbor serve --dataset harness-hub/UltraTerminals
236
+ ```
237
+
238
+ A task's `task.toml` names its pinned image (`[environment] docker_image`) when the catalog row has one (2382 of
239
+ 2597 tasks), so sandboxes that cannot build images (HF Sandboxes) pull it. The other 215 keep only their
240
+ Dockerfile, which Harbor with Docker builds. `data/*.jsonl` still describes each task (`pool`, review records,
241
+ licenses); the folder name is its `task_id`. License texts are in `licenses/`.
licenses/access-review-LICENSE.txt ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+
licenses/cedar-integration-tests-LICENSE ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
licenses/cedar-integration-tests-NOTICE ADDED
@@ -0,0 +1 @@
 
 
1
+ Copyright Cedar Contributors
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/Dockerfile ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ FROM --platform=linux/amd64 registry.hf.space/harness-hub-scale800-go-055c69f17f410bee-starter-v1@sha256:9dfb6b7417f54d78d50e6e6bdd951b854ed8da8f5f1782f4fe563a85e1cd0b7a
2
+ WORKDIR /testbed
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ squirrel.test
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/.travis.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: go
2
+
3
+ go:
4
+ - 1.11.x
5
+ - 1.12.x
6
+ - 1.13.x
7
+
8
+ services:
9
+ - mysql
10
+ - postgresql
11
+
12
+ # Setting sudo access to false will let Travis CI use containers rather than
13
+ # VMs to run the tests. For more details see:
14
+ # - http://docs.travis-ci.com/user/workers/container-based-infrastructure/
15
+ # - http://docs.travis-ci.com/user/workers/standard-infrastructure/
16
+ sudo: false
17
+
18
+ before_script:
19
+ - mysql -e 'CREATE DATABASE squirrel;'
20
+ - psql -c 'CREATE DATABASE squirrel;' -U postgres
21
+
22
+ script:
23
+ - go test
24
+ - cd integration
25
+ - go test -args -driver sqlite3
26
+ - go test -args -driver mysql -dataSource travis@/squirrel
27
+ - go test -args -driver postgres -dataSource 'postgres://postgres@localhost/squirrel?sslmode=disable'
28
+
29
+ notifications:
30
+ irc: "irc.freenode.net#masterminds"
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/LICENSE ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Squirrel: The Masterminds
4
+ Copyright (c) 2014-2015, Lann Martin. Copyright (C) 2015-2016, Google. Copyright (C) 2015, Matt Farina and Matt Butcher.
5
+
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![Stability: Maintenance](https://masterminds.github.io/stability/maintenance.svg)](https://masterminds.github.io/stability/maintenance.html)
2
+ ### Squirrel is "complete".
3
+ Bug fixes will still be merged (slowly). Bug reports are welcome, but I will not necessarily respond to them. If another fork (or substantially similar project) actively improves on what Squirrel does, let me know and I may link to it here.
4
+
5
+
6
+ # Squirrel - fluent SQL generator for Go
7
+
8
+ ```go
9
+ import "github.com/Masterminds/squirrel"
10
+ ```
11
+
12
+
13
+ [![GoDoc](https://godoc.org/github.com/Masterminds/squirrel?status.png)](https://godoc.org/github.com/Masterminds/squirrel)
14
+ [![Build Status](https://api.travis-ci.org/Masterminds/squirrel.svg?branch=master)](https://travis-ci.org/Masterminds/squirrel)
15
+
16
+ **Squirrel is not an ORM.** For an application of Squirrel, check out
17
+ [structable, a table-struct mapper](https://github.com/Masterminds/structable)
18
+
19
+
20
+ Squirrel helps you build SQL queries from composable parts:
21
+
22
+ ```go
23
+ import sq "github.com/Masterminds/squirrel"
24
+
25
+ users := sq.Select("*").From("users").Join("emails USING (email_id)")
26
+
27
+ active := users.Where(sq.Eq{"deleted_at": nil})
28
+
29
+ sql, args, err := active.ToSql()
30
+
31
+ sql == "SELECT * FROM users JOIN emails USING (email_id) WHERE deleted_at IS NULL"
32
+ ```
33
+
34
+ ```go
35
+ sql, args, err := sq.
36
+ Insert("users").Columns("name", "age").
37
+ Values("moe", 13).Values("larry", sq.Expr("? + 5", 12)).
38
+ ToSql()
39
+
40
+ sql == "INSERT INTO users (name,age) VALUES (?,?),(?,? + 5)"
41
+ ```
42
+
43
+ Squirrel can also execute queries directly:
44
+
45
+ ```go
46
+ stooges := users.Where(sq.Eq{"username": []string{"moe", "larry", "curly", "shemp"}})
47
+ three_stooges := stooges.Limit(3)
48
+ rows, err := three_stooges.RunWith(db).Query()
49
+
50
+ // Behaves like:
51
+ rows, err := db.Query("SELECT * FROM users WHERE username IN (?,?,?,?) LIMIT 3",
52
+ "moe", "larry", "curly", "shemp")
53
+ ```
54
+
55
+ Squirrel makes conditional query building a breeze:
56
+
57
+ ```go
58
+ if len(q) > 0 {
59
+ users = users.Where("name LIKE ?", fmt.Sprint("%", q, "%"))
60
+ }
61
+ ```
62
+
63
+ Squirrel wants to make your life easier:
64
+
65
+ ```go
66
+ // StmtCache caches Prepared Stmts for you
67
+ dbCache := sq.NewStmtCache(db)
68
+
69
+ // StatementBuilder keeps your syntax neat
70
+ mydb := sq.StatementBuilder.RunWith(dbCache)
71
+ select_users := mydb.Select("*").From("users")
72
+ ```
73
+
74
+ Squirrel loves PostgreSQL:
75
+
76
+ ```go
77
+ psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar)
78
+
79
+ // You use question marks for placeholders...
80
+ sql, _, _ := psql.Select("*").From("elephants").Where("name IN (?,?)", "Dumbo", "Verna").ToSql()
81
+
82
+ /// ...squirrel replaces them using PlaceholderFormat.
83
+ sql == "SELECT * FROM elephants WHERE name IN ($1,$2)"
84
+
85
+
86
+ /// You can retrieve id ...
87
+ query := sq.Insert("nodes").
88
+ Columns("uuid", "type", "data").
89
+ Values(node.Uuid, node.Type, node.Data).
90
+ Suffix("RETURNING \"id\"").
91
+ RunWith(m.db).
92
+ PlaceholderFormat(sq.Dollar)
93
+
94
+ query.QueryRow().Scan(&node.id)
95
+ ```
96
+
97
+ You can escape question marks by inserting two question marks:
98
+
99
+ ```sql
100
+ SELECT * FROM nodes WHERE meta->'format' ??| array[?,?]
101
+ ```
102
+
103
+ will generate with the Dollar Placeholder:
104
+
105
+ ```sql
106
+ SELECT * FROM nodes WHERE meta->'format' ?| array[$1,$2]
107
+ ```
108
+
109
+ ## FAQ
110
+
111
+ * **How can I build an IN query on composite keys / tuples, e.g. `WHERE (col1, col2) IN ((1,2),(3,4))`? ([#104](https://github.com/Masterminds/squirrel/issues/104))**
112
+
113
+ Squirrel does not explicitly support tuples, but you can get the same effect with e.g.:
114
+
115
+ ```go
116
+ sq.Or{
117
+ sq.Eq{"col1": 1, "col2": 2},
118
+ sq.Eq{"col1": 3, "col2": 4}}
119
+ ```
120
+
121
+ ```sql
122
+ WHERE (col1 = 1 AND col2 = 2) OR (col1 = 3 AND col2 = 4)
123
+ ```
124
+
125
+ (which should produce the same query plan as the tuple version)
126
+
127
+ * **Why doesn't `Eq{"mynumber": []uint8{1,2,3}}` turn into an `IN` query? ([#114](https://github.com/Masterminds/squirrel/issues/114))**
128
+
129
+ Values of type `[]byte` are handled specially by `database/sql`. In Go, [`byte` is just an alias of `uint8`](https://golang.org/pkg/builtin/#byte), so there is no way to distinguish `[]uint8` from `[]byte`.
130
+
131
+ * **Some features are poorly documented!**
132
+
133
+ This isn't a frequent complaints section!
134
+
135
+ * **Some features are poorly documented?**
136
+
137
+ Yes. The tests should be considered a part of the documentation; take a look at those for ideas on how to express more complex queries.
138
+
139
+ ## License
140
+
141
+ Squirrel is released under the
142
+ [MIT License](http://www.opensource.org/licenses/MIT).
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/case.go ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "errors"
6
+
7
+ "github.com/lann/builder"
8
+ )
9
+
10
+ func init() {
11
+ builder.Register(CaseBuilder{}, caseData{})
12
+ }
13
+
14
+ // sqlizerBuffer is a helper that allows to write many Sqlizers one by one
15
+ // without constant checks for errors that may come from Sqlizer
16
+ type sqlizerBuffer struct {
17
+ bytes.Buffer
18
+ args []interface{}
19
+ err error
20
+ }
21
+
22
+ // WriteSql converts Sqlizer to SQL strings and writes it to buffer
23
+ func (b *sqlizerBuffer) WriteSql(item Sqlizer) {
24
+ if b.err != nil {
25
+ return
26
+ }
27
+
28
+ var str string
29
+ var args []interface{}
30
+ str, args, b.err = nestedToSql(item)
31
+
32
+ if b.err != nil {
33
+ return
34
+ }
35
+
36
+ b.WriteString(str)
37
+ b.WriteByte(' ')
38
+ b.args = append(b.args, args...)
39
+ }
40
+
41
+ func (b *sqlizerBuffer) ToSql() (string, []interface{}, error) {
42
+ return b.String(), b.args, b.err
43
+ }
44
+
45
+ // whenPart is a helper structure to describe SQLs "WHEN ... THEN ..." expression
46
+ type whenPart struct {
47
+ when Sqlizer
48
+ then Sqlizer
49
+ }
50
+
51
+ func newWhenPart(when interface{}, then interface{}) whenPart {
52
+ return whenPart{newPart(when), newPart(then)}
53
+ }
54
+
55
+ // caseData holds all the data required to build a CASE SQL construct
56
+ type caseData struct {
57
+ What Sqlizer
58
+ WhenParts []whenPart
59
+ Else Sqlizer
60
+ }
61
+
62
+ // ToSql implements Sqlizer
63
+ func (d *caseData) ToSql() (sqlStr string, args []interface{}, err error) {
64
+ if len(d.WhenParts) == 0 {
65
+ err = errors.New("case expression must contain at lease one WHEN clause")
66
+
67
+ return
68
+ }
69
+
70
+ sql := sqlizerBuffer{}
71
+
72
+ sql.WriteString("CASE ")
73
+ if d.What != nil {
74
+ sql.WriteSql(d.What)
75
+ }
76
+
77
+ for _, p := range d.WhenParts {
78
+ sql.WriteString("WHEN ")
79
+ sql.WriteSql(p.when)
80
+ sql.WriteString("THEN ")
81
+ sql.WriteSql(p.then)
82
+ }
83
+
84
+ if d.Else != nil {
85
+ sql.WriteString("ELSE ")
86
+ sql.WriteSql(d.Else)
87
+ }
88
+
89
+ sql.WriteString("END")
90
+
91
+ return sql.ToSql()
92
+ }
93
+
94
+ // CaseBuilder builds SQL CASE construct which could be used as parts of queries.
95
+ type CaseBuilder builder.Builder
96
+
97
+ // ToSql builds the query into a SQL string and bound args.
98
+ func (b CaseBuilder) ToSql() (string, []interface{}, error) {
99
+ data := builder.GetStruct(b).(caseData)
100
+ return data.ToSql()
101
+ }
102
+
103
+ // MustSql builds the query into a SQL string and bound args.
104
+ // It panics if there are any errors.
105
+ func (b CaseBuilder) MustSql() (string, []interface{}) {
106
+ sql, args, err := b.ToSql()
107
+ if err != nil {
108
+ panic(err)
109
+ }
110
+ return sql, args
111
+ }
112
+
113
+ // what sets optional value for CASE construct "CASE [value] ..."
114
+ func (b CaseBuilder) what(expr interface{}) CaseBuilder {
115
+ return builder.Set(b, "What", newPart(expr)).(CaseBuilder)
116
+ }
117
+
118
+ // When adds "WHEN ... THEN ..." part to CASE construct
119
+ func (b CaseBuilder) When(when interface{}, then interface{}) CaseBuilder {
120
+ // TODO: performance hint: replace slice of WhenPart with just slice of parts
121
+ // where even indices of the slice belong to "when"s and odd indices belong to "then"s
122
+ return builder.Append(b, "WhenParts", newWhenPart(when, then)).(CaseBuilder)
123
+ }
124
+
125
+ // What sets optional "ELSE ..." part for CASE construct
126
+ func (b CaseBuilder) Else(expr interface{}) CaseBuilder {
127
+ return builder.Set(b, "Else", newPart(expr)).(CaseBuilder)
128
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/delete.go ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "database/sql"
6
+ "fmt"
7
+ "strings"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ type deleteData struct {
13
+ PlaceholderFormat PlaceholderFormat
14
+ RunWith BaseRunner
15
+ Prefixes []Sqlizer
16
+ From string
17
+ WhereParts []Sqlizer
18
+ OrderBys []string
19
+ Limit string
20
+ Offset string
21
+ Suffixes []Sqlizer
22
+ }
23
+
24
+ func (d *deleteData) Exec() (sql.Result, error) {
25
+ if d.RunWith == nil {
26
+ return nil, RunnerNotSet
27
+ }
28
+ return ExecWith(d.RunWith, d)
29
+ }
30
+
31
+ func (d *deleteData) ToSql() (sqlStr string, args []interface{}, err error) {
32
+ if len(d.From) == 0 {
33
+ err = fmt.Errorf("delete statements must specify a From table")
34
+ return
35
+ }
36
+
37
+ sql := &bytes.Buffer{}
38
+
39
+ if len(d.Prefixes) > 0 {
40
+ args, err = appendToSql(d.Prefixes, sql, " ", args)
41
+ if err != nil {
42
+ return
43
+ }
44
+
45
+ sql.WriteString(" ")
46
+ }
47
+
48
+ sql.WriteString("DELETE FROM ")
49
+ sql.WriteString(d.From)
50
+
51
+ if len(d.WhereParts) > 0 {
52
+ sql.WriteString(" WHERE ")
53
+ args, err = appendToSql(d.WhereParts, sql, " AND ", args)
54
+ if err != nil {
55
+ return
56
+ }
57
+ }
58
+
59
+ if len(d.OrderBys) > 0 {
60
+ sql.WriteString(" ORDER BY ")
61
+ sql.WriteString(strings.Join(d.OrderBys, ", "))
62
+ }
63
+
64
+ if len(d.Limit) > 0 {
65
+ sql.WriteString(" LIMIT ")
66
+ sql.WriteString(d.Limit)
67
+ }
68
+
69
+ if len(d.Offset) > 0 {
70
+ sql.WriteString(" OFFSET ")
71
+ sql.WriteString(d.Offset)
72
+ }
73
+
74
+ if len(d.Suffixes) > 0 {
75
+ sql.WriteString(" ")
76
+ args, err = appendToSql(d.Suffixes, sql, " ", args)
77
+ if err != nil {
78
+ return
79
+ }
80
+ }
81
+
82
+ sqlStr, err = d.PlaceholderFormat.ReplacePlaceholders(sql.String())
83
+ return
84
+ }
85
+
86
+ // Builder
87
+
88
+ // DeleteBuilder builds SQL DELETE statements.
89
+ type DeleteBuilder builder.Builder
90
+
91
+ func init() {
92
+ builder.Register(DeleteBuilder{}, deleteData{})
93
+ }
94
+
95
+ // Format methods
96
+
97
+ // PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the
98
+ // query.
99
+ func (b DeleteBuilder) PlaceholderFormat(f PlaceholderFormat) DeleteBuilder {
100
+ return builder.Set(b, "PlaceholderFormat", f).(DeleteBuilder)
101
+ }
102
+
103
+ // Runner methods
104
+
105
+ // RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.
106
+ func (b DeleteBuilder) RunWith(runner BaseRunner) DeleteBuilder {
107
+ return setRunWith(b, runner).(DeleteBuilder)
108
+ }
109
+
110
+ // Exec builds and Execs the query with the Runner set by RunWith.
111
+ func (b DeleteBuilder) Exec() (sql.Result, error) {
112
+ data := builder.GetStruct(b).(deleteData)
113
+ return data.Exec()
114
+ }
115
+
116
+ // SQL methods
117
+
118
+ // ToSql builds the query into a SQL string and bound args.
119
+ func (b DeleteBuilder) ToSql() (string, []interface{}, error) {
120
+ data := builder.GetStruct(b).(deleteData)
121
+ return data.ToSql()
122
+ }
123
+
124
+ // MustSql builds the query into a SQL string and bound args.
125
+ // It panics if there are any errors.
126
+ func (b DeleteBuilder) MustSql() (string, []interface{}) {
127
+ sql, args, err := b.ToSql()
128
+ if err != nil {
129
+ panic(err)
130
+ }
131
+ return sql, args
132
+ }
133
+
134
+ // Prefix adds an expression to the beginning of the query
135
+ func (b DeleteBuilder) Prefix(sql string, args ...interface{}) DeleteBuilder {
136
+ return b.PrefixExpr(Expr(sql, args...))
137
+ }
138
+
139
+ // PrefixExpr adds an expression to the very beginning of the query
140
+ func (b DeleteBuilder) PrefixExpr(expr Sqlizer) DeleteBuilder {
141
+ return builder.Append(b, "Prefixes", expr).(DeleteBuilder)
142
+ }
143
+
144
+ // From sets the table to be deleted from.
145
+ func (b DeleteBuilder) From(from string) DeleteBuilder {
146
+ return builder.Set(b, "From", from).(DeleteBuilder)
147
+ }
148
+
149
+ // Where adds WHERE expressions to the query.
150
+ //
151
+ // See SelectBuilder.Where for more information.
152
+ func (b DeleteBuilder) Where(pred interface{}, args ...interface{}) DeleteBuilder {
153
+ return builder.Append(b, "WhereParts", newWherePart(pred, args...)).(DeleteBuilder)
154
+ }
155
+
156
+ // OrderBy adds ORDER BY expressions to the query.
157
+ func (b DeleteBuilder) OrderBy(orderBys ...string) DeleteBuilder {
158
+ return builder.Extend(b, "OrderBys", orderBys).(DeleteBuilder)
159
+ }
160
+
161
+ // Limit sets a LIMIT clause on the query.
162
+ func (b DeleteBuilder) Limit(limit uint64) DeleteBuilder {
163
+ return builder.Set(b, "Limit", fmt.Sprintf("%d", limit)).(DeleteBuilder)
164
+ }
165
+
166
+ // Offset sets a OFFSET clause on the query.
167
+ func (b DeleteBuilder) Offset(offset uint64) DeleteBuilder {
168
+ return builder.Set(b, "Offset", fmt.Sprintf("%d", offset)).(DeleteBuilder)
169
+ }
170
+
171
+ // Suffix adds an expression to the end of the query
172
+ func (b DeleteBuilder) Suffix(sql string, args ...interface{}) DeleteBuilder {
173
+ return b.SuffixExpr(Expr(sql, args...))
174
+ }
175
+
176
+ // SuffixExpr adds an expression to the end of the query
177
+ func (b DeleteBuilder) SuffixExpr(expr Sqlizer) DeleteBuilder {
178
+ return builder.Append(b, "Suffixes", expr).(DeleteBuilder)
179
+ }
180
+
181
+ func (b DeleteBuilder) Query() (*sql.Rows, error) {
182
+ data := builder.GetStruct(b).(deleteData)
183
+ return data.Query()
184
+ }
185
+
186
+ func (d *deleteData) Query() (*sql.Rows, error) {
187
+ if d.RunWith == nil {
188
+ return nil, RunnerNotSet
189
+ }
190
+ return QueryWith(d.RunWith, d)
191
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/delete_ctx.go ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ func (d *deleteData) ExecContext(ctx context.Context) (sql.Result, error) {
13
+ if d.RunWith == nil {
14
+ return nil, RunnerNotSet
15
+ }
16
+ ctxRunner, ok := d.RunWith.(ExecerContext)
17
+ if !ok {
18
+ return nil, NoContextSupport
19
+ }
20
+ return ExecContextWith(ctx, ctxRunner, d)
21
+ }
22
+
23
+ func (d *deleteData) QueryContext(ctx context.Context) (*sql.Rows, error) {
24
+ if d.RunWith == nil {
25
+ return nil, RunnerNotSet
26
+ }
27
+ ctxRunner, ok := d.RunWith.(QueryerContext)
28
+ if !ok {
29
+ return nil, NoContextSupport
30
+ }
31
+ return QueryContextWith(ctx, ctxRunner, d)
32
+ }
33
+
34
+ func (d *deleteData) QueryRowContext(ctx context.Context) RowScanner {
35
+ if d.RunWith == nil {
36
+ return &Row{err: RunnerNotSet}
37
+ }
38
+ queryRower, ok := d.RunWith.(QueryRowerContext)
39
+ if !ok {
40
+ if _, ok := d.RunWith.(QueryerContext); !ok {
41
+ return &Row{err: RunnerNotQueryRunner}
42
+ }
43
+ return &Row{err: NoContextSupport}
44
+ }
45
+ return QueryRowContextWith(ctx, queryRower, d)
46
+ }
47
+
48
+ // ExecContext builds and ExecContexts the query with the Runner set by RunWith.
49
+ func (b DeleteBuilder) ExecContext(ctx context.Context) (sql.Result, error) {
50
+ data := builder.GetStruct(b).(deleteData)
51
+ return data.ExecContext(ctx)
52
+ }
53
+
54
+ // QueryContext builds and QueryContexts the query with the Runner set by RunWith.
55
+ func (b DeleteBuilder) QueryContext(ctx context.Context) (*sql.Rows, error) {
56
+ data := builder.GetStruct(b).(deleteData)
57
+ return data.QueryContext(ctx)
58
+ }
59
+
60
+ // QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.
61
+ func (b DeleteBuilder) QueryRowContext(ctx context.Context) RowScanner {
62
+ data := builder.GetStruct(b).(deleteData)
63
+ return data.QueryRowContext(ctx)
64
+ }
65
+
66
+ // ScanContext is a shortcut for QueryRowContext().Scan.
67
+ func (b DeleteBuilder) ScanContext(ctx context.Context, dest ...interface{}) error {
68
+ return b.QueryRowContext(ctx).Scan(dest...)
69
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/expr.go ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "database/sql/driver"
6
+ "fmt"
7
+ "reflect"
8
+ "sort"
9
+ "strings"
10
+ )
11
+
12
+ const (
13
+ // Portable true/false literals.
14
+ sqlTrue = "(1=1)"
15
+ sqlFalse = "(1=0)"
16
+ )
17
+
18
+ type expr struct {
19
+ sql string
20
+ args []interface{}
21
+ }
22
+
23
+ // Expr builds an expression from a SQL fragment and arguments.
24
+ //
25
+ // Ex:
26
+ // Expr("FROM_UNIXTIME(?)", t)
27
+ func Expr(sql string, args ...interface{}) Sqlizer {
28
+ return expr{sql: sql, args: args}
29
+ }
30
+
31
+ func (e expr) ToSql() (sql string, args []interface{}, err error) {
32
+ simple := true
33
+ for _, arg := range e.args {
34
+ if _, ok := arg.(Sqlizer); ok {
35
+ simple = false
36
+ }
37
+ }
38
+ if simple {
39
+ return e.sql, e.args, nil
40
+ }
41
+
42
+ buf := &bytes.Buffer{}
43
+ ap := e.args
44
+ sp := e.sql
45
+
46
+ var isql string
47
+ var iargs []interface{}
48
+
49
+ for err == nil && len(ap) > 0 && len(sp) > 0 {
50
+ i := strings.Index(sp, "?")
51
+ if i < 0 {
52
+ // no more placeholders
53
+ break
54
+ }
55
+ if len(sp) > i+1 && sp[i+1:i+2] == "?" {
56
+ // escaped "??"; append it and step past
57
+ buf.WriteString(sp[:i+2])
58
+ sp = sp[i+2:]
59
+ continue
60
+ }
61
+
62
+ if as, ok := ap[0].(Sqlizer); ok {
63
+ // sqlizer argument; expand it and append the result
64
+ isql, iargs, err = as.ToSql()
65
+ buf.WriteString(sp[:i])
66
+ buf.WriteString(isql)
67
+ args = append(args, iargs...)
68
+ } else {
69
+ // normal argument; append it and the placeholder
70
+ buf.WriteString(sp[:i+1])
71
+ args = append(args, ap[0])
72
+ }
73
+
74
+ // step past the argument and placeholder
75
+ ap = ap[1:]
76
+ sp = sp[i+1:]
77
+ }
78
+
79
+ // append the remaining sql and arguments
80
+ buf.WriteString(sp)
81
+ return buf.String(), append(args, ap...), err
82
+ }
83
+
84
+ type concatExpr []interface{}
85
+
86
+ func (ce concatExpr) ToSql() (sql string, args []interface{}, err error) {
87
+ for _, part := range ce {
88
+ switch p := part.(type) {
89
+ case string:
90
+ sql += p
91
+ case Sqlizer:
92
+ pSql, pArgs, err := p.ToSql()
93
+ if err != nil {
94
+ return "", nil, err
95
+ }
96
+ sql += pSql
97
+ args = append(args, pArgs...)
98
+ default:
99
+ return "", nil, fmt.Errorf("%#v is not a string or Sqlizer", part)
100
+ }
101
+ }
102
+ return
103
+ }
104
+
105
+ // ConcatExpr builds an expression by concatenating strings and other expressions.
106
+ //
107
+ // Ex:
108
+ // name_expr := Expr("CONCAT(?, ' ', ?)", firstName, lastName)
109
+ // ConcatExpr("COALESCE(full_name,", name_expr, ")")
110
+ func ConcatExpr(parts ...interface{}) concatExpr {
111
+ return concatExpr(parts)
112
+ }
113
+
114
+ // aliasExpr helps to alias part of SQL query generated with underlying "expr"
115
+ type aliasExpr struct {
116
+ expr Sqlizer
117
+ alias string
118
+ }
119
+
120
+ // Alias allows to define alias for column in SelectBuilder. Useful when column is
121
+ // defined as complex expression like IF or CASE
122
+ // Ex:
123
+ // .Column(Alias(caseStmt, "case_column"))
124
+ func Alias(expr Sqlizer, alias string) aliasExpr {
125
+ return aliasExpr{expr, alias}
126
+ }
127
+
128
+ func (e aliasExpr) ToSql() (sql string, args []interface{}, err error) {
129
+ sql, args, err = e.expr.ToSql()
130
+ if err == nil {
131
+ sql = fmt.Sprintf("(%s) AS %s", sql, e.alias)
132
+ }
133
+ return
134
+ }
135
+
136
+ // Eq is syntactic sugar for use with Where/Having/Set methods.
137
+ type Eq map[string]interface{}
138
+
139
+ func (eq Eq) toSQL(useNotOpr bool) (sql string, args []interface{}, err error) {
140
+ if len(eq) == 0 {
141
+ // Empty Sql{} evaluates to true.
142
+ sql = sqlTrue
143
+ return
144
+ }
145
+
146
+ var (
147
+ exprs []string
148
+ equalOpr = "="
149
+ inOpr = "IN"
150
+ nullOpr = "IS"
151
+ inEmptyExpr = sqlFalse
152
+ )
153
+
154
+ if useNotOpr {
155
+ equalOpr = "<>"
156
+ inOpr = "NOT IN"
157
+ nullOpr = "IS NOT"
158
+ inEmptyExpr = sqlTrue
159
+ }
160
+
161
+ sortedKeys := getSortedKeys(eq)
162
+ for _, key := range sortedKeys {
163
+ var expr string
164
+ val := eq[key]
165
+
166
+ switch v := val.(type) {
167
+ case driver.Valuer:
168
+ if val, err = v.Value(); err != nil {
169
+ return
170
+ }
171
+ }
172
+
173
+ r := reflect.ValueOf(val)
174
+ if r.Kind() == reflect.Ptr {
175
+ if r.IsNil() {
176
+ val = nil
177
+ } else {
178
+ val = r.Elem().Interface()
179
+ }
180
+ }
181
+
182
+ if val == nil {
183
+ expr = fmt.Sprintf("%s %s NULL", key, nullOpr)
184
+ } else {
185
+ if isListType(val) {
186
+ valVal := reflect.ValueOf(val)
187
+ if valVal.Len() == 0 {
188
+ expr = inEmptyExpr
189
+ if args == nil {
190
+ args = []interface{}{}
191
+ }
192
+ } else {
193
+ for i := 0; i < valVal.Len(); i++ {
194
+ args = append(args, valVal.Index(i).Interface())
195
+ }
196
+ expr = fmt.Sprintf("%s %s (%s)", key, inOpr, Placeholders(valVal.Len()))
197
+ }
198
+ } else {
199
+ expr = fmt.Sprintf("%s %s ?", key, equalOpr)
200
+ args = append(args, val)
201
+ }
202
+ }
203
+ exprs = append(exprs, expr)
204
+ }
205
+ sql = strings.Join(exprs, " AND ")
206
+ return
207
+ }
208
+
209
+ func (eq Eq) ToSql() (sql string, args []interface{}, err error) {
210
+ return eq.toSQL(false)
211
+ }
212
+
213
+ // NotEq is syntactic sugar for use with Where/Having/Set methods.
214
+ // Ex:
215
+ // .Where(NotEq{"id": 1}) == "id <> 1"
216
+ type NotEq Eq
217
+
218
+ func (neq NotEq) ToSql() (sql string, args []interface{}, err error) {
219
+ return Eq(neq).toSQL(true)
220
+ }
221
+
222
+ // Like is syntactic sugar for use with LIKE conditions.
223
+ // Ex:
224
+ // .Where(Like{"name": "%irrel"})
225
+ type Like map[string]interface{}
226
+
227
+ func (lk Like) toSql(opr string) (sql string, args []interface{}, err error) {
228
+ var exprs []string
229
+ for key, val := range lk {
230
+ expr := ""
231
+
232
+ switch v := val.(type) {
233
+ case driver.Valuer:
234
+ if val, err = v.Value(); err != nil {
235
+ return
236
+ }
237
+ }
238
+
239
+ if val == nil {
240
+ err = fmt.Errorf("cannot use null with like operators")
241
+ return
242
+ } else {
243
+ if isListType(val) {
244
+ err = fmt.Errorf("cannot use array or slice with like operators")
245
+ return
246
+ } else {
247
+ expr = fmt.Sprintf("%s %s ?", key, opr)
248
+ args = append(args, val)
249
+ }
250
+ }
251
+ exprs = append(exprs, expr)
252
+ }
253
+ sql = strings.Join(exprs, " AND ")
254
+ return
255
+ }
256
+
257
+ func (lk Like) ToSql() (sql string, args []interface{}, err error) {
258
+ return lk.toSql("LIKE")
259
+ }
260
+
261
+ // NotLike is syntactic sugar for use with LIKE conditions.
262
+ // Ex:
263
+ // .Where(NotLike{"name": "%irrel"})
264
+ type NotLike Like
265
+
266
+ func (nlk NotLike) ToSql() (sql string, args []interface{}, err error) {
267
+ return Like(nlk).toSql("NOT LIKE")
268
+ }
269
+
270
+ // ILike is syntactic sugar for use with ILIKE conditions.
271
+ // Ex:
272
+ // .Where(ILike{"name": "sq%"})
273
+ type ILike Like
274
+
275
+ func (ilk ILike) ToSql() (sql string, args []interface{}, err error) {
276
+ return Like(ilk).toSql("ILIKE")
277
+ }
278
+
279
+ // NotILike is syntactic sugar for use with ILIKE conditions.
280
+ // Ex:
281
+ // .Where(NotILike{"name": "sq%"})
282
+ type NotILike Like
283
+
284
+ func (nilk NotILike) ToSql() (sql string, args []interface{}, err error) {
285
+ return Like(nilk).toSql("NOT ILIKE")
286
+ }
287
+
288
+ // Lt is syntactic sugar for use with Where/Having/Set methods.
289
+ // Ex:
290
+ // .Where(Lt{"id": 1})
291
+ type Lt map[string]interface{}
292
+
293
+ func (lt Lt) toSql(opposite, orEq bool) (sql string, args []interface{}, err error) {
294
+ var (
295
+ exprs []string
296
+ opr = "<"
297
+ )
298
+
299
+ if opposite {
300
+ opr = ">"
301
+ }
302
+
303
+ if orEq {
304
+ opr = fmt.Sprintf("%s%s", opr, "=")
305
+ }
306
+
307
+ sortedKeys := getSortedKeys(lt)
308
+ for _, key := range sortedKeys {
309
+ var expr string
310
+ val := lt[key]
311
+
312
+ switch v := val.(type) {
313
+ case driver.Valuer:
314
+ if val, err = v.Value(); err != nil {
315
+ return
316
+ }
317
+ }
318
+
319
+ if val == nil {
320
+ err = fmt.Errorf("cannot use null with less than or greater than operators")
321
+ return
322
+ }
323
+ if isListType(val) {
324
+ err = fmt.Errorf("cannot use array or slice with less than or greater than operators")
325
+ return
326
+ }
327
+ expr = fmt.Sprintf("%s %s ?", key, opr)
328
+ args = append(args, val)
329
+
330
+ exprs = append(exprs, expr)
331
+ }
332
+ sql = strings.Join(exprs, " AND ")
333
+ return
334
+ }
335
+
336
+ func (lt Lt) ToSql() (sql string, args []interface{}, err error) {
337
+ return lt.toSql(false, false)
338
+ }
339
+
340
+ // LtOrEq is syntactic sugar for use with Where/Having/Set methods.
341
+ // Ex:
342
+ // .Where(LtOrEq{"id": 1}) == "id <= 1"
343
+ type LtOrEq Lt
344
+
345
+ func (ltOrEq LtOrEq) ToSql() (sql string, args []interface{}, err error) {
346
+ return Lt(ltOrEq).toSql(false, true)
347
+ }
348
+
349
+ // Gt is syntactic sugar for use with Where/Having/Set methods.
350
+ // Ex:
351
+ // .Where(Gt{"id": 1}) == "id > 1"
352
+ type Gt Lt
353
+
354
+ func (gt Gt) ToSql() (sql string, args []interface{}, err error) {
355
+ return Lt(gt).toSql(true, false)
356
+ }
357
+
358
+ // GtOrEq is syntactic sugar for use with Where/Having/Set methods.
359
+ // Ex:
360
+ // .Where(GtOrEq{"id": 1}) == "id >= 1"
361
+ type GtOrEq Lt
362
+
363
+ func (gtOrEq GtOrEq) ToSql() (sql string, args []interface{}, err error) {
364
+ return Lt(gtOrEq).toSql(true, true)
365
+ }
366
+
367
+ type conj []Sqlizer
368
+
369
+ func (c conj) join(sep, defaultExpr string) (sql string, args []interface{}, err error) {
370
+ if len(c) == 0 {
371
+ return defaultExpr, []interface{}{}, nil
372
+ }
373
+ var sqlParts []string
374
+ for _, sqlizer := range c {
375
+ partSQL, partArgs, err := nestedToSql(sqlizer)
376
+ if err != nil {
377
+ return "", nil, err
378
+ }
379
+ if partSQL != "" {
380
+ sqlParts = append(sqlParts, partSQL)
381
+ args = append(args, partArgs...)
382
+ }
383
+ }
384
+ if len(sqlParts) > 0 {
385
+ sql = fmt.Sprintf("(%s)", strings.Join(sqlParts, sep))
386
+ }
387
+ return
388
+ }
389
+
390
+ // And conjunction Sqlizers
391
+ type And conj
392
+
393
+ func (a And) ToSql() (string, []interface{}, error) {
394
+ return conj(a).join(" AND ", sqlTrue)
395
+ }
396
+
397
+ // Or conjunction Sqlizers
398
+ type Or conj
399
+
400
+ func (o Or) ToSql() (string, []interface{}, error) {
401
+ return conj(o).join(" OR ", sqlFalse)
402
+ }
403
+
404
+ func getSortedKeys(exp map[string]interface{}) []string {
405
+ sortedKeys := make([]string, 0, len(exp))
406
+ for k := range exp {
407
+ sortedKeys = append(sortedKeys, k)
408
+ }
409
+ sort.Strings(sortedKeys)
410
+ return sortedKeys
411
+ }
412
+
413
+ func isListType(val interface{}) bool {
414
+ if driver.IsValue(val) {
415
+ return false
416
+ }
417
+ valVal := reflect.ValueOf(val)
418
+ return valVal.Kind() == reflect.Array || valVal.Kind() == reflect.Slice
419
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/go.mod ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module github.com/Masterminds/squirrel
2
+
3
+ go 1.14
4
+
5
+ require (
6
+ github.com/davecgh/go-spew v1.1.1 // indirect
7
+ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
8
+ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
9
+ github.com/pmezard/go-difflib v1.0.0 // indirect
10
+ github.com/stretchr/testify v1.2.2
11
+ )
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/go.sum ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3
+ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
4
+ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
5
+ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
6
+ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
7
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9
+ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
10
+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/insert.go ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "database/sql"
6
+ "errors"
7
+ "fmt"
8
+ "io"
9
+ "sort"
10
+ "strings"
11
+
12
+ "github.com/lann/builder"
13
+ )
14
+
15
+ type insertData struct {
16
+ PlaceholderFormat PlaceholderFormat
17
+ RunWith BaseRunner
18
+ Prefixes []Sqlizer
19
+ StatementKeyword string
20
+ Options []string
21
+ Into string
22
+ Columns []string
23
+ Values [][]interface{}
24
+ Suffixes []Sqlizer
25
+ Select *SelectBuilder
26
+ }
27
+
28
+ func (d *insertData) Exec() (sql.Result, error) {
29
+ if d.RunWith == nil {
30
+ return nil, RunnerNotSet
31
+ }
32
+ return ExecWith(d.RunWith, d)
33
+ }
34
+
35
+ func (d *insertData) Query() (*sql.Rows, error) {
36
+ if d.RunWith == nil {
37
+ return nil, RunnerNotSet
38
+ }
39
+ return QueryWith(d.RunWith, d)
40
+ }
41
+
42
+ func (d *insertData) QueryRow() RowScanner {
43
+ if d.RunWith == nil {
44
+ return &Row{err: RunnerNotSet}
45
+ }
46
+ queryRower, ok := d.RunWith.(QueryRower)
47
+ if !ok {
48
+ return &Row{err: RunnerNotQueryRunner}
49
+ }
50
+ return QueryRowWith(queryRower, d)
51
+ }
52
+
53
+ func (d *insertData) ToSql() (sqlStr string, args []interface{}, err error) {
54
+ if len(d.Into) == 0 {
55
+ err = errors.New("insert statements must specify a table")
56
+ return
57
+ }
58
+ if len(d.Values) == 0 && d.Select == nil {
59
+ err = errors.New("insert statements must have at least one set of values or select clause")
60
+ return
61
+ }
62
+
63
+ sql := &bytes.Buffer{}
64
+
65
+ if len(d.Prefixes) > 0 {
66
+ args, err = appendToSql(d.Prefixes, sql, " ", args)
67
+ if err != nil {
68
+ return
69
+ }
70
+
71
+ sql.WriteString(" ")
72
+ }
73
+
74
+ if d.StatementKeyword == "" {
75
+ sql.WriteString("INSERT ")
76
+ } else {
77
+ sql.WriteString(d.StatementKeyword)
78
+ sql.WriteString(" ")
79
+ }
80
+
81
+ if len(d.Options) > 0 {
82
+ sql.WriteString(strings.Join(d.Options, " "))
83
+ sql.WriteString(" ")
84
+ }
85
+
86
+ sql.WriteString("INTO ")
87
+ sql.WriteString(d.Into)
88
+ sql.WriteString(" ")
89
+
90
+ if len(d.Columns) > 0 {
91
+ sql.WriteString("(")
92
+ sql.WriteString(strings.Join(d.Columns, ","))
93
+ sql.WriteString(") ")
94
+ }
95
+
96
+ if d.Select != nil {
97
+ args, err = d.appendSelectToSQL(sql, args)
98
+ } else {
99
+ args, err = d.appendValuesToSQL(sql, args)
100
+ }
101
+ if err != nil {
102
+ return
103
+ }
104
+
105
+ if len(d.Suffixes) > 0 {
106
+ sql.WriteString(" ")
107
+ args, err = appendToSql(d.Suffixes, sql, " ", args)
108
+ if err != nil {
109
+ return
110
+ }
111
+ }
112
+
113
+ sqlStr, err = d.PlaceholderFormat.ReplacePlaceholders(sql.String())
114
+ return
115
+ }
116
+
117
+ func (d *insertData) appendValuesToSQL(w io.Writer, args []interface{}) ([]interface{}, error) {
118
+ if len(d.Values) == 0 {
119
+ return args, errors.New("values for insert statements are not set")
120
+ }
121
+
122
+ io.WriteString(w, "VALUES ")
123
+
124
+ valuesStrings := make([]string, len(d.Values))
125
+ for r, row := range d.Values {
126
+ valueStrings := make([]string, len(row))
127
+ for v, val := range row {
128
+ if vs, ok := val.(Sqlizer); ok {
129
+ vsql, vargs, err := vs.ToSql()
130
+ if err != nil {
131
+ return nil, err
132
+ }
133
+ valueStrings[v] = vsql
134
+ args = append(args, vargs...)
135
+ } else {
136
+ valueStrings[v] = "?"
137
+ args = append(args, val)
138
+ }
139
+ }
140
+ valuesStrings[r] = fmt.Sprintf("(%s)", strings.Join(valueStrings, ","))
141
+ }
142
+
143
+ io.WriteString(w, strings.Join(valuesStrings, ","))
144
+
145
+ return args, nil
146
+ }
147
+
148
+ func (d *insertData) appendSelectToSQL(w io.Writer, args []interface{}) ([]interface{}, error) {
149
+ if d.Select == nil {
150
+ return args, errors.New("select clause for insert statements are not set")
151
+ }
152
+
153
+ selectClause, sArgs, err := d.Select.ToSql()
154
+ if err != nil {
155
+ return args, err
156
+ }
157
+
158
+ io.WriteString(w, selectClause)
159
+ args = append(args, sArgs...)
160
+
161
+ return args, nil
162
+ }
163
+
164
+ // Builder
165
+
166
+ // InsertBuilder builds SQL INSERT statements.
167
+ type InsertBuilder builder.Builder
168
+
169
+ func init() {
170
+ builder.Register(InsertBuilder{}, insertData{})
171
+ }
172
+
173
+ // Format methods
174
+
175
+ // PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the
176
+ // query.
177
+ func (b InsertBuilder) PlaceholderFormat(f PlaceholderFormat) InsertBuilder {
178
+ return builder.Set(b, "PlaceholderFormat", f).(InsertBuilder)
179
+ }
180
+
181
+ // Runner methods
182
+
183
+ // RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.
184
+ func (b InsertBuilder) RunWith(runner BaseRunner) InsertBuilder {
185
+ return setRunWith(b, runner).(InsertBuilder)
186
+ }
187
+
188
+ // Exec builds and Execs the query with the Runner set by RunWith.
189
+ func (b InsertBuilder) Exec() (sql.Result, error) {
190
+ data := builder.GetStruct(b).(insertData)
191
+ return data.Exec()
192
+ }
193
+
194
+ // Query builds and Querys the query with the Runner set by RunWith.
195
+ func (b InsertBuilder) Query() (*sql.Rows, error) {
196
+ data := builder.GetStruct(b).(insertData)
197
+ return data.Query()
198
+ }
199
+
200
+ // QueryRow builds and QueryRows the query with the Runner set by RunWith.
201
+ func (b InsertBuilder) QueryRow() RowScanner {
202
+ data := builder.GetStruct(b).(insertData)
203
+ return data.QueryRow()
204
+ }
205
+
206
+ // Scan is a shortcut for QueryRow().Scan.
207
+ func (b InsertBuilder) Scan(dest ...interface{}) error {
208
+ return b.QueryRow().Scan(dest...)
209
+ }
210
+
211
+ // SQL methods
212
+
213
+ // ToSql builds the query into a SQL string and bound args.
214
+ func (b InsertBuilder) ToSql() (string, []interface{}, error) {
215
+ data := builder.GetStruct(b).(insertData)
216
+ return data.ToSql()
217
+ }
218
+
219
+ // MustSql builds the query into a SQL string and bound args.
220
+ // It panics if there are any errors.
221
+ func (b InsertBuilder) MustSql() (string, []interface{}) {
222
+ sql, args, err := b.ToSql()
223
+ if err != nil {
224
+ panic(err)
225
+ }
226
+ return sql, args
227
+ }
228
+
229
+ // Prefix adds an expression to the beginning of the query
230
+ func (b InsertBuilder) Prefix(sql string, args ...interface{}) InsertBuilder {
231
+ return b.PrefixExpr(Expr(sql, args...))
232
+ }
233
+
234
+ // PrefixExpr adds an expression to the very beginning of the query
235
+ func (b InsertBuilder) PrefixExpr(expr Sqlizer) InsertBuilder {
236
+ return builder.Append(b, "Prefixes", expr).(InsertBuilder)
237
+ }
238
+
239
+ // Options adds keyword options before the INTO clause of the query.
240
+ func (b InsertBuilder) Options(options ...string) InsertBuilder {
241
+ return builder.Extend(b, "Options", options).(InsertBuilder)
242
+ }
243
+
244
+ // Into sets the INTO clause of the query.
245
+ func (b InsertBuilder) Into(into string) InsertBuilder {
246
+ return builder.Set(b, "Into", into).(InsertBuilder)
247
+ }
248
+
249
+ // Columns adds insert columns to the query.
250
+ func (b InsertBuilder) Columns(columns ...string) InsertBuilder {
251
+ return builder.Extend(b, "Columns", columns).(InsertBuilder)
252
+ }
253
+
254
+ // Values adds a single row's values to the query.
255
+ func (b InsertBuilder) Values(values ...interface{}) InsertBuilder {
256
+ return builder.Append(b, "Values", values).(InsertBuilder)
257
+ }
258
+
259
+ // Suffix adds an expression to the end of the query
260
+ func (b InsertBuilder) Suffix(sql string, args ...interface{}) InsertBuilder {
261
+ return b.SuffixExpr(Expr(sql, args...))
262
+ }
263
+
264
+ // SuffixExpr adds an expression to the end of the query
265
+ func (b InsertBuilder) SuffixExpr(expr Sqlizer) InsertBuilder {
266
+ return builder.Append(b, "Suffixes", expr).(InsertBuilder)
267
+ }
268
+
269
+ // SetMap set columns and values for insert builder from a map of column name and value
270
+ // note that it will reset all previous columns and values was set if any
271
+ func (b InsertBuilder) SetMap(clauses map[string]interface{}) InsertBuilder {
272
+ // Keep the columns in a consistent order by sorting the column key string.
273
+ cols := make([]string, 0, len(clauses))
274
+ for col := range clauses {
275
+ cols = append(cols, col)
276
+ }
277
+ sort.Strings(cols)
278
+
279
+ vals := make([]interface{}, 0, len(clauses))
280
+ for _, col := range cols {
281
+ vals = append(vals, clauses[col])
282
+ }
283
+
284
+ b = builder.Set(b, "Columns", cols).(InsertBuilder)
285
+ b = builder.Set(b, "Values", [][]interface{}{vals}).(InsertBuilder)
286
+
287
+ return b
288
+ }
289
+
290
+ // Select set Select clause for insert query
291
+ // If Values and Select are used, then Select has higher priority
292
+ func (b InsertBuilder) Select(sb SelectBuilder) InsertBuilder {
293
+ return builder.Set(b, "Select", &sb).(InsertBuilder)
294
+ }
295
+
296
+ func (b InsertBuilder) statementKeyword(keyword string) InsertBuilder {
297
+ return builder.Set(b, "StatementKeyword", keyword).(InsertBuilder)
298
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/insert_ctx.go ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ func (d *insertData) ExecContext(ctx context.Context) (sql.Result, error) {
13
+ if d.RunWith == nil {
14
+ return nil, RunnerNotSet
15
+ }
16
+ ctxRunner, ok := d.RunWith.(ExecerContext)
17
+ if !ok {
18
+ return nil, NoContextSupport
19
+ }
20
+ return ExecContextWith(ctx, ctxRunner, d)
21
+ }
22
+
23
+ func (d *insertData) QueryContext(ctx context.Context) (*sql.Rows, error) {
24
+ if d.RunWith == nil {
25
+ return nil, RunnerNotSet
26
+ }
27
+ ctxRunner, ok := d.RunWith.(QueryerContext)
28
+ if !ok {
29
+ return nil, NoContextSupport
30
+ }
31
+ return QueryContextWith(ctx, ctxRunner, d)
32
+ }
33
+
34
+ func (d *insertData) QueryRowContext(ctx context.Context) RowScanner {
35
+ if d.RunWith == nil {
36
+ return &Row{err: RunnerNotSet}
37
+ }
38
+ queryRower, ok := d.RunWith.(QueryRowerContext)
39
+ if !ok {
40
+ if _, ok := d.RunWith.(QueryerContext); !ok {
41
+ return &Row{err: RunnerNotQueryRunner}
42
+ }
43
+ return &Row{err: NoContextSupport}
44
+ }
45
+ return QueryRowContextWith(ctx, queryRower, d)
46
+ }
47
+
48
+ // ExecContext builds and ExecContexts the query with the Runner set by RunWith.
49
+ func (b InsertBuilder) ExecContext(ctx context.Context) (sql.Result, error) {
50
+ data := builder.GetStruct(b).(insertData)
51
+ return data.ExecContext(ctx)
52
+ }
53
+
54
+ // QueryContext builds and QueryContexts the query with the Runner set by RunWith.
55
+ func (b InsertBuilder) QueryContext(ctx context.Context) (*sql.Rows, error) {
56
+ data := builder.GetStruct(b).(insertData)
57
+ return data.QueryContext(ctx)
58
+ }
59
+
60
+ // QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.
61
+ func (b InsertBuilder) QueryRowContext(ctx context.Context) RowScanner {
62
+ data := builder.GetStruct(b).(insertData)
63
+ return data.QueryRowContext(ctx)
64
+ }
65
+
66
+ // ScanContext is a shortcut for QueryRowContext().Scan.
67
+ func (b InsertBuilder) ScanContext(ctx context.Context, dest ...interface{}) error {
68
+ return b.QueryRowContext(ctx).Scan(dest...)
69
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/doc.go ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ // This is a tests-only package.
2
+ package integration
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/go.mod ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module github.com/Masterminds/squirrel/integration
2
+
3
+ go 1.12
4
+
5
+ require (
6
+ github.com/Masterminds/squirrel v1.1.0
7
+ github.com/go-sql-driver/mysql v1.4.1
8
+ github.com/lib/pq v1.2.0
9
+ github.com/mattn/go-sqlite3 v1.13.0
10
+ github.com/stretchr/testify v1.4.0
11
+ google.golang.org/appengine v1.6.5 // indirect
12
+ )
13
+
14
+ replace github.com/Masterminds/squirrel => ../
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/integration/go.sum ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ github.com/Masterminds/squirrel v1.1.0 h1:baP1qLdoQCeTw3ifCdOq2dkYc6vGcmRdaociKLbEJXs=
2
+ github.com/Masterminds/squirrel v1.1.0/go.mod h1:yaPeOnPG5ZRwL9oKdTsO/prlkPbXWZlRVMQ/gGlzIuA=
3
+ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4
+ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6
+ github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
7
+ github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
8
+ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
9
+ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
10
+ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
11
+ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
12
+ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
13
+ github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
14
+ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
15
+ github.com/mattn/go-sqlite3 v1.13.0 h1:LnJI81JidiW9r7pS/hXe6cFeO5EXNq7KbfvoJLRI69c=
16
+ github.com/mattn/go-sqlite3 v1.13.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
17
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
18
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
19
+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
20
+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
21
+ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
22
+ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
23
+ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
24
+ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
25
+ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
26
+ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
27
+ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
28
+ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
29
+ google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
30
+ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
31
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
32
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
33
+ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
34
+ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/part.go ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "fmt"
5
+ "io"
6
+ )
7
+
8
+ type part struct {
9
+ pred interface{}
10
+ args []interface{}
11
+ }
12
+
13
+ func newPart(pred interface{}, args ...interface{}) Sqlizer {
14
+ return &part{pred, args}
15
+ }
16
+
17
+ func (p part) ToSql() (sql string, args []interface{}, err error) {
18
+ switch pred := p.pred.(type) {
19
+ case nil:
20
+ // no-op
21
+ case Sqlizer:
22
+ sql, args, err = nestedToSql(pred)
23
+ case string:
24
+ sql = pred
25
+ args = p.args
26
+ default:
27
+ err = fmt.Errorf("expected string or Sqlizer, not %T", pred)
28
+ }
29
+ return
30
+ }
31
+
32
+ func nestedToSql(s Sqlizer) (string, []interface{}, error) {
33
+ if raw, ok := s.(rawSqlizer); ok {
34
+ return raw.toSqlRaw()
35
+ } else {
36
+ return s.ToSql()
37
+ }
38
+ }
39
+
40
+ func appendToSql(parts []Sqlizer, w io.Writer, sep string, args []interface{}) ([]interface{}, error) {
41
+ for i, p := range parts {
42
+ partSql, partArgs, err := nestedToSql(p)
43
+ if err != nil {
44
+ return nil, err
45
+ } else if len(partSql) == 0 {
46
+ continue
47
+ }
48
+
49
+ if i > 0 {
50
+ _, err := io.WriteString(w, sep)
51
+ if err != nil {
52
+ return nil, err
53
+ }
54
+ }
55
+
56
+ _, err = io.WriteString(w, partSql)
57
+ if err != nil {
58
+ return nil, err
59
+ }
60
+ args = append(args, partArgs...)
61
+ }
62
+ return args, nil
63
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/placeholder.go ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "fmt"
6
+ "strings"
7
+ )
8
+
9
+ // PlaceholderFormat is the interface that wraps the ReplacePlaceholders method.
10
+ //
11
+ // ReplacePlaceholders takes a SQL statement and replaces each question mark
12
+ // placeholder with a (possibly different) SQL placeholder.
13
+ type PlaceholderFormat interface {
14
+ ReplacePlaceholders(sql string) (string, error)
15
+ }
16
+
17
+ type placeholderDebugger interface {
18
+ debugPlaceholder() string
19
+ }
20
+
21
+ var (
22
+ // Question is a PlaceholderFormat instance that leaves placeholders as
23
+ // question marks.
24
+ Question = questionFormat{}
25
+
26
+ // Dollar is a PlaceholderFormat instance that replaces placeholders with
27
+ // dollar-prefixed positional placeholders (e.g. $1, $2, $3).
28
+ Dollar = dollarFormat{}
29
+
30
+ // Colon is a PlaceholderFormat instance that replaces placeholders with
31
+ // colon-prefixed positional placeholders (e.g. :1, :2, :3).
32
+ Colon = colonFormat{}
33
+
34
+ // AtP is a PlaceholderFormat instance that replaces placeholders with
35
+ // "@p"-prefixed positional placeholders (e.g. @p1, @p2, @p3).
36
+ AtP = atpFormat{}
37
+ )
38
+
39
+ type questionFormat struct{}
40
+
41
+ func (questionFormat) ReplacePlaceholders(sql string) (string, error) {
42
+ return sql, nil
43
+ }
44
+
45
+ func (questionFormat) debugPlaceholder() string {
46
+ return "?"
47
+ }
48
+
49
+ type dollarFormat struct{}
50
+
51
+ func (dollarFormat) ReplacePlaceholders(sql string) (string, error) {
52
+ return replacePositionalPlaceholders(sql, "$")
53
+ }
54
+
55
+ func (dollarFormat) debugPlaceholder() string {
56
+ return "$"
57
+ }
58
+
59
+ type colonFormat struct{}
60
+
61
+ func (colonFormat) ReplacePlaceholders(sql string) (string, error) {
62
+ return replacePositionalPlaceholders(sql, ":")
63
+ }
64
+
65
+ func (colonFormat) debugPlaceholder() string {
66
+ return ":"
67
+ }
68
+
69
+ type atpFormat struct{}
70
+
71
+ func (atpFormat) ReplacePlaceholders(sql string) (string, error) {
72
+ return replacePositionalPlaceholders(sql, "@p")
73
+ }
74
+
75
+ func (atpFormat) debugPlaceholder() string {
76
+ return "@p"
77
+ }
78
+
79
+ // Placeholders returns a string with count ? placeholders joined with commas.
80
+ func Placeholders(count int) string {
81
+ if count < 1 {
82
+ return ""
83
+ }
84
+
85
+ return strings.Repeat(",?", count)[1:]
86
+ }
87
+
88
+ func replacePositionalPlaceholders(sql, prefix string) (string, error) {
89
+ buf := &bytes.Buffer{}
90
+ i := 0
91
+ for {
92
+ p := strings.Index(sql, "?")
93
+ if p == -1 {
94
+ break
95
+ }
96
+
97
+ if len(sql[p:]) > 1 && sql[p:p+2] == "??" { // escape ?? => ?
98
+ buf.WriteString(sql[:p])
99
+ buf.WriteString("?")
100
+ if len(sql[p:]) == 1 {
101
+ break
102
+ }
103
+ sql = sql[p+2:]
104
+ } else {
105
+ i++
106
+ buf.WriteString(sql[:p])
107
+ fmt.Fprintf(buf, "%s%d", prefix, i)
108
+ sql = sql[p+1:]
109
+ }
110
+ }
111
+
112
+ buf.WriteString(sql)
113
+ return buf.String(), nil
114
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/row.go ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ // RowScanner is the interface that wraps the Scan method.
4
+ //
5
+ // Scan behaves like database/sql.Row.Scan.
6
+ type RowScanner interface {
7
+ Scan(...interface{}) error
8
+ }
9
+
10
+ // Row wraps database/sql.Row to let squirrel return new errors on Scan.
11
+ type Row struct {
12
+ RowScanner
13
+ err error
14
+ }
15
+
16
+ // Scan returns Row.err or calls RowScanner.Scan.
17
+ func (r *Row) Scan(dest ...interface{}) error {
18
+ if r.err != nil {
19
+ return r.err
20
+ }
21
+ return r.RowScanner.Scan(dest...)
22
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/select.go ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "database/sql"
6
+ "fmt"
7
+ "strings"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ type selectData struct {
13
+ PlaceholderFormat PlaceholderFormat
14
+ RunWith BaseRunner
15
+ Prefixes []Sqlizer
16
+ Options []string
17
+ Columns []Sqlizer
18
+ From Sqlizer
19
+ Joins []Sqlizer
20
+ WhereParts []Sqlizer
21
+ GroupBys []string
22
+ HavingParts []Sqlizer
23
+ OrderByParts []Sqlizer
24
+ Limit string
25
+ Offset string
26
+ Suffixes []Sqlizer
27
+ }
28
+
29
+ func (d *selectData) Exec() (sql.Result, error) {
30
+ if d.RunWith == nil {
31
+ return nil, RunnerNotSet
32
+ }
33
+ return ExecWith(d.RunWith, d)
34
+ }
35
+
36
+ func (d *selectData) Query() (*sql.Rows, error) {
37
+ if d.RunWith == nil {
38
+ return nil, RunnerNotSet
39
+ }
40
+ return QueryWith(d.RunWith, d)
41
+ }
42
+
43
+ func (d *selectData) QueryRow() RowScanner {
44
+ if d.RunWith == nil {
45
+ return &Row{err: RunnerNotSet}
46
+ }
47
+ queryRower, ok := d.RunWith.(QueryRower)
48
+ if !ok {
49
+ return &Row{err: RunnerNotQueryRunner}
50
+ }
51
+ return QueryRowWith(queryRower, d)
52
+ }
53
+
54
+ func (d *selectData) ToSql() (sqlStr string, args []interface{}, err error) {
55
+ sqlStr, args, err = d.toSqlRaw()
56
+ if err != nil {
57
+ return
58
+ }
59
+
60
+ sqlStr, err = d.PlaceholderFormat.ReplacePlaceholders(sqlStr)
61
+ return
62
+ }
63
+
64
+ func (d *selectData) toSqlRaw() (sqlStr string, args []interface{}, err error) {
65
+ if len(d.Columns) == 0 {
66
+ err = fmt.Errorf("select statements must have at least one result column")
67
+ return
68
+ }
69
+
70
+ sql := &bytes.Buffer{}
71
+
72
+ if len(d.Prefixes) > 0 {
73
+ args, err = appendToSql(d.Prefixes, sql, " ", args)
74
+ if err != nil {
75
+ return
76
+ }
77
+
78
+ sql.WriteString(" ")
79
+ }
80
+
81
+ sql.WriteString("SELECT ")
82
+
83
+ if len(d.Options) > 0 {
84
+ sql.WriteString(strings.Join(d.Options, " "))
85
+ sql.WriteString(" ")
86
+ }
87
+
88
+ if len(d.Columns) > 0 {
89
+ args, err = appendToSql(d.Columns, sql, ", ", args)
90
+ if err != nil {
91
+ return
92
+ }
93
+ }
94
+
95
+ if d.From != nil {
96
+ sql.WriteString(" FROM ")
97
+ args, err = appendToSql([]Sqlizer{d.From}, sql, "", args)
98
+ if err != nil {
99
+ return
100
+ }
101
+ }
102
+
103
+ if len(d.Joins) > 0 {
104
+ sql.WriteString(" ")
105
+ args, err = appendToSql(d.Joins, sql, " ", args)
106
+ if err != nil {
107
+ return
108
+ }
109
+ }
110
+
111
+ if len(d.WhereParts) > 0 {
112
+ sql.WriteString(" WHERE ")
113
+ args, err = appendToSql(d.WhereParts, sql, " AND ", args)
114
+ if err != nil {
115
+ return
116
+ }
117
+ }
118
+
119
+ if len(d.GroupBys) > 0 {
120
+ sql.WriteString(" GROUP BY ")
121
+ sql.WriteString(strings.Join(d.GroupBys, ", "))
122
+ }
123
+
124
+ if len(d.HavingParts) > 0 {
125
+ sql.WriteString(" HAVING ")
126
+ args, err = appendToSql(d.HavingParts, sql, " AND ", args)
127
+ if err != nil {
128
+ return
129
+ }
130
+ }
131
+
132
+ if len(d.OrderByParts) > 0 {
133
+ sql.WriteString(" ORDER BY ")
134
+ args, err = appendToSql(d.OrderByParts, sql, ", ", args)
135
+ if err != nil {
136
+ return
137
+ }
138
+ }
139
+
140
+ if len(d.Limit) > 0 {
141
+ sql.WriteString(" LIMIT ")
142
+ sql.WriteString(d.Limit)
143
+ }
144
+
145
+ if len(d.Offset) > 0 {
146
+ sql.WriteString(" OFFSET ")
147
+ sql.WriteString(d.Offset)
148
+ }
149
+
150
+ if len(d.Suffixes) > 0 {
151
+ sql.WriteString(" ")
152
+
153
+ args, err = appendToSql(d.Suffixes, sql, " ", args)
154
+ if err != nil {
155
+ return
156
+ }
157
+ }
158
+
159
+ sqlStr = sql.String()
160
+ return
161
+ }
162
+
163
+ // Builder
164
+
165
+ // SelectBuilder builds SQL SELECT statements.
166
+ type SelectBuilder builder.Builder
167
+
168
+ func init() {
169
+ builder.Register(SelectBuilder{}, selectData{})
170
+ }
171
+
172
+ // Format methods
173
+
174
+ // PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the
175
+ // query.
176
+ func (b SelectBuilder) PlaceholderFormat(f PlaceholderFormat) SelectBuilder {
177
+ return builder.Set(b, "PlaceholderFormat", f).(SelectBuilder)
178
+ }
179
+
180
+ // Runner methods
181
+
182
+ // RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.
183
+ // For most cases runner will be a database connection.
184
+ //
185
+ // Internally we use this to mock out the database connection for testing.
186
+ func (b SelectBuilder) RunWith(runner BaseRunner) SelectBuilder {
187
+ return setRunWith(b, runner).(SelectBuilder)
188
+ }
189
+
190
+ // Exec builds and Execs the query with the Runner set by RunWith.
191
+ func (b SelectBuilder) Exec() (sql.Result, error) {
192
+ data := builder.GetStruct(b).(selectData)
193
+ return data.Exec()
194
+ }
195
+
196
+ // Query builds and Querys the query with the Runner set by RunWith.
197
+ func (b SelectBuilder) Query() (*sql.Rows, error) {
198
+ data := builder.GetStruct(b).(selectData)
199
+ return data.Query()
200
+ }
201
+
202
+ // QueryRow builds and QueryRows the query with the Runner set by RunWith.
203
+ func (b SelectBuilder) QueryRow() RowScanner {
204
+ data := builder.GetStruct(b).(selectData)
205
+ return data.QueryRow()
206
+ }
207
+
208
+ // Scan is a shortcut for QueryRow().Scan.
209
+ func (b SelectBuilder) Scan(dest ...interface{}) error {
210
+ return b.QueryRow().Scan(dest...)
211
+ }
212
+
213
+ // SQL methods
214
+
215
+ // ToSql builds the query into a SQL string and bound args.
216
+ func (b SelectBuilder) ToSql() (string, []interface{}, error) {
217
+ data := builder.GetStruct(b).(selectData)
218
+ return data.ToSql()
219
+ }
220
+
221
+ func (b SelectBuilder) toSqlRaw() (string, []interface{}, error) {
222
+ data := builder.GetStruct(b).(selectData)
223
+ return data.toSqlRaw()
224
+ }
225
+
226
+ // MustSql builds the query into a SQL string and bound args.
227
+ // It panics if there are any errors.
228
+ func (b SelectBuilder) MustSql() (string, []interface{}) {
229
+ sql, args, err := b.ToSql()
230
+ if err != nil {
231
+ panic(err)
232
+ }
233
+ return sql, args
234
+ }
235
+
236
+ // Prefix adds an expression to the beginning of the query
237
+ func (b SelectBuilder) Prefix(sql string, args ...interface{}) SelectBuilder {
238
+ return b.PrefixExpr(Expr(sql, args...))
239
+ }
240
+
241
+ // PrefixExpr adds an expression to the very beginning of the query
242
+ func (b SelectBuilder) PrefixExpr(expr Sqlizer) SelectBuilder {
243
+ return builder.Append(b, "Prefixes", expr).(SelectBuilder)
244
+ }
245
+
246
+ // Distinct adds a DISTINCT clause to the query.
247
+ func (b SelectBuilder) Distinct() SelectBuilder {
248
+ return b.Options("DISTINCT")
249
+ }
250
+
251
+ // Options adds select option to the query
252
+ func (b SelectBuilder) Options(options ...string) SelectBuilder {
253
+ return builder.Extend(b, "Options", options).(SelectBuilder)
254
+ }
255
+
256
+ // Columns adds result columns to the query.
257
+ func (b SelectBuilder) Columns(columns ...string) SelectBuilder {
258
+ parts := make([]interface{}, 0, len(columns))
259
+ for _, str := range columns {
260
+ parts = append(parts, newPart(str))
261
+ }
262
+ return builder.Extend(b, "Columns", parts).(SelectBuilder)
263
+ }
264
+
265
+ // RemoveColumns remove all columns from query.
266
+ // Must add a new column with Column or Columns methods, otherwise
267
+ // return a error.
268
+ func (b SelectBuilder) RemoveColumns() SelectBuilder {
269
+ return builder.Delete(b, "Columns").(SelectBuilder)
270
+ }
271
+
272
+ // Column adds a result column to the query.
273
+ // Unlike Columns, Column accepts args which will be bound to placeholders in
274
+ // the columns string, for example:
275
+ // Column("IF(col IN ("+squirrel.Placeholders(3)+"), 1, 0) as col", 1, 2, 3)
276
+ func (b SelectBuilder) Column(column interface{}, args ...interface{}) SelectBuilder {
277
+ return builder.Append(b, "Columns", newPart(column, args...)).(SelectBuilder)
278
+ }
279
+
280
+ // From sets the FROM clause of the query.
281
+ func (b SelectBuilder) From(from string) SelectBuilder {
282
+ return builder.Set(b, "From", newPart(from)).(SelectBuilder)
283
+ }
284
+
285
+ // FromSelect sets a subquery into the FROM clause of the query.
286
+ func (b SelectBuilder) FromSelect(from SelectBuilder, alias string) SelectBuilder {
287
+ // Prevent misnumbered parameters in nested selects (#183).
288
+ from = from.PlaceholderFormat(Question)
289
+ return builder.Set(b, "From", Alias(from, alias)).(SelectBuilder)
290
+ }
291
+
292
+ // JoinClause adds a join clause to the query.
293
+ func (b SelectBuilder) JoinClause(pred interface{}, args ...interface{}) SelectBuilder {
294
+ return builder.Append(b, "Joins", newPart(pred, args...)).(SelectBuilder)
295
+ }
296
+
297
+ // Join adds a JOIN clause to the query.
298
+ func (b SelectBuilder) Join(join string, rest ...interface{}) SelectBuilder {
299
+ return b.JoinClause("JOIN "+join, rest...)
300
+ }
301
+
302
+ // LeftJoin adds a LEFT JOIN clause to the query.
303
+ func (b SelectBuilder) LeftJoin(join string, rest ...interface{}) SelectBuilder {
304
+ return b.JoinClause("LEFT JOIN "+join, rest...)
305
+ }
306
+
307
+ // RightJoin adds a RIGHT JOIN clause to the query.
308
+ func (b SelectBuilder) RightJoin(join string, rest ...interface{}) SelectBuilder {
309
+ return b.JoinClause("RIGHT JOIN "+join, rest...)
310
+ }
311
+
312
+ // InnerJoin adds a INNER JOIN clause to the query.
313
+ func (b SelectBuilder) InnerJoin(join string, rest ...interface{}) SelectBuilder {
314
+ return b.JoinClause("INNER JOIN "+join, rest...)
315
+ }
316
+
317
+ // CrossJoin adds a CROSS JOIN clause to the query.
318
+ func (b SelectBuilder) CrossJoin(join string, rest ...interface{}) SelectBuilder {
319
+ return b.JoinClause("CROSS JOIN "+join, rest...)
320
+ }
321
+
322
+ // Where adds an expression to the WHERE clause of the query.
323
+ //
324
+ // Expressions are ANDed together in the generated SQL.
325
+ //
326
+ // Where accepts several types for its pred argument:
327
+ //
328
+ // nil OR "" - ignored.
329
+ //
330
+ // string - SQL expression.
331
+ // If the expression has SQL placeholders then a set of arguments must be passed
332
+ // as well, one for each placeholder.
333
+ //
334
+ // map[string]interface{} OR Eq - map of SQL expressions to values. Each key is
335
+ // transformed into an expression like "<key> = ?", with the corresponding value
336
+ // bound to the placeholder. If the value is nil, the expression will be "<key>
337
+ // IS NULL". If the value is an array or slice, the expression will be "<key> IN
338
+ // (?,?,...)", with one placeholder for each item in the value. These expressions
339
+ // are ANDed together.
340
+ //
341
+ // Where will panic if pred isn't any of the above types.
342
+ func (b SelectBuilder) Where(pred interface{}, args ...interface{}) SelectBuilder {
343
+ if pred == nil || pred == "" {
344
+ return b
345
+ }
346
+ return builder.Append(b, "WhereParts", newWherePart(pred, args...)).(SelectBuilder)
347
+ }
348
+
349
+ // GroupBy adds GROUP BY expressions to the query.
350
+ func (b SelectBuilder) GroupBy(groupBys ...string) SelectBuilder {
351
+ return builder.Extend(b, "GroupBys", groupBys).(SelectBuilder)
352
+ }
353
+
354
+ // Having adds an expression to the HAVING clause of the query.
355
+ //
356
+ // See Where.
357
+ func (b SelectBuilder) Having(pred interface{}, rest ...interface{}) SelectBuilder {
358
+ return builder.Append(b, "HavingParts", newWherePart(pred, rest...)).(SelectBuilder)
359
+ }
360
+
361
+ // OrderByClause adds ORDER BY clause to the query.
362
+ func (b SelectBuilder) OrderByClause(pred interface{}, args ...interface{}) SelectBuilder {
363
+ return builder.Append(b, "OrderByParts", newPart(pred, args...)).(SelectBuilder)
364
+ }
365
+
366
+ // OrderBy adds ORDER BY expressions to the query.
367
+ func (b SelectBuilder) OrderBy(orderBys ...string) SelectBuilder {
368
+ for _, orderBy := range orderBys {
369
+ b = b.OrderByClause(orderBy)
370
+ }
371
+
372
+ return b
373
+ }
374
+
375
+ // Limit sets a LIMIT clause on the query.
376
+ func (b SelectBuilder) Limit(limit uint64) SelectBuilder {
377
+ return builder.Set(b, "Limit", fmt.Sprintf("%d", limit)).(SelectBuilder)
378
+ }
379
+
380
+ // Limit ALL allows to access all records with limit
381
+ func (b SelectBuilder) RemoveLimit() SelectBuilder {
382
+ return builder.Delete(b, "Limit").(SelectBuilder)
383
+ }
384
+
385
+ // Offset sets a OFFSET clause on the query.
386
+ func (b SelectBuilder) Offset(offset uint64) SelectBuilder {
387
+ return builder.Set(b, "Offset", fmt.Sprintf("%d", offset)).(SelectBuilder)
388
+ }
389
+
390
+ // RemoveOffset removes OFFSET clause.
391
+ func (b SelectBuilder) RemoveOffset() SelectBuilder {
392
+ return builder.Delete(b, "Offset").(SelectBuilder)
393
+ }
394
+
395
+ // Suffix adds an expression to the end of the query
396
+ func (b SelectBuilder) Suffix(sql string, args ...interface{}) SelectBuilder {
397
+ return b.SuffixExpr(Expr(sql, args...))
398
+ }
399
+
400
+ // SuffixExpr adds an expression to the end of the query
401
+ func (b SelectBuilder) SuffixExpr(expr Sqlizer) SelectBuilder {
402
+ return builder.Append(b, "Suffixes", expr).(SelectBuilder)
403
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/select_ctx.go ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ func (d *selectData) ExecContext(ctx context.Context) (sql.Result, error) {
13
+ if d.RunWith == nil {
14
+ return nil, RunnerNotSet
15
+ }
16
+ ctxRunner, ok := d.RunWith.(ExecerContext)
17
+ if !ok {
18
+ return nil, NoContextSupport
19
+ }
20
+ return ExecContextWith(ctx, ctxRunner, d)
21
+ }
22
+
23
+ func (d *selectData) QueryContext(ctx context.Context) (*sql.Rows, error) {
24
+ if d.RunWith == nil {
25
+ return nil, RunnerNotSet
26
+ }
27
+ ctxRunner, ok := d.RunWith.(QueryerContext)
28
+ if !ok {
29
+ return nil, NoContextSupport
30
+ }
31
+ return QueryContextWith(ctx, ctxRunner, d)
32
+ }
33
+
34
+ func (d *selectData) QueryRowContext(ctx context.Context) RowScanner {
35
+ if d.RunWith == nil {
36
+ return &Row{err: RunnerNotSet}
37
+ }
38
+ queryRower, ok := d.RunWith.(QueryRowerContext)
39
+ if !ok {
40
+ if _, ok := d.RunWith.(QueryerContext); !ok {
41
+ return &Row{err: RunnerNotQueryRunner}
42
+ }
43
+ return &Row{err: NoContextSupport}
44
+ }
45
+ return QueryRowContextWith(ctx, queryRower, d)
46
+ }
47
+
48
+ // ExecContext builds and ExecContexts the query with the Runner set by RunWith.
49
+ func (b SelectBuilder) ExecContext(ctx context.Context) (sql.Result, error) {
50
+ data := builder.GetStruct(b).(selectData)
51
+ return data.ExecContext(ctx)
52
+ }
53
+
54
+ // QueryContext builds and QueryContexts the query with the Runner set by RunWith.
55
+ func (b SelectBuilder) QueryContext(ctx context.Context) (*sql.Rows, error) {
56
+ data := builder.GetStruct(b).(selectData)
57
+ return data.QueryContext(ctx)
58
+ }
59
+
60
+ // QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.
61
+ func (b SelectBuilder) QueryRowContext(ctx context.Context) RowScanner {
62
+ data := builder.GetStruct(b).(selectData)
63
+ return data.QueryRowContext(ctx)
64
+ }
65
+
66
+ // ScanContext is a shortcut for QueryRowContext().Scan.
67
+ func (b SelectBuilder) ScanContext(ctx context.Context, dest ...interface{}) error {
68
+ return b.QueryRowContext(ctx).Scan(dest...)
69
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/squirrel.go ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Package squirrel provides a fluent SQL generator.
2
+ //
3
+ // See https://github.com/Masterminds/squirrel for examples.
4
+ package squirrel
5
+
6
+ import (
7
+ "bytes"
8
+ "database/sql"
9
+ "fmt"
10
+ "strings"
11
+
12
+ "github.com/lann/builder"
13
+ )
14
+
15
+ // Sqlizer is the interface that wraps the ToSql method.
16
+ //
17
+ // ToSql returns a SQL representation of the Sqlizer, along with a slice of args
18
+ // as passed to e.g. database/sql.Exec. It can also return an error.
19
+ type Sqlizer interface {
20
+ ToSql() (string, []interface{}, error)
21
+ }
22
+
23
+ // rawSqlizer is expected to do what Sqlizer does, but without finalizing placeholders.
24
+ // This is useful for nested queries.
25
+ type rawSqlizer interface {
26
+ toSqlRaw() (string, []interface{}, error)
27
+ }
28
+
29
+ // Execer is the interface that wraps the Exec method.
30
+ //
31
+ // Exec executes the given query as implemented by database/sql.Exec.
32
+ type Execer interface {
33
+ Exec(query string, args ...interface{}) (sql.Result, error)
34
+ }
35
+
36
+ // Queryer is the interface that wraps the Query method.
37
+ //
38
+ // Query executes the given query as implemented by database/sql.Query.
39
+ type Queryer interface {
40
+ Query(query string, args ...interface{}) (*sql.Rows, error)
41
+ }
42
+
43
+ // QueryRower is the interface that wraps the QueryRow method.
44
+ //
45
+ // QueryRow executes the given query as implemented by database/sql.QueryRow.
46
+ type QueryRower interface {
47
+ QueryRow(query string, args ...interface{}) RowScanner
48
+ }
49
+
50
+ // BaseRunner groups the Execer and Queryer interfaces.
51
+ type BaseRunner interface {
52
+ Execer
53
+ Queryer
54
+ }
55
+
56
+ // Runner groups the Execer, Queryer, and QueryRower interfaces.
57
+ type Runner interface {
58
+ Execer
59
+ Queryer
60
+ QueryRower
61
+ }
62
+
63
+ // WrapStdSql wraps a type implementing the standard SQL interface with methods that
64
+ // squirrel expects.
65
+ func WrapStdSql(stdSql StdSql) Runner {
66
+ return &stdsqlRunner{stdSql}
67
+ }
68
+
69
+ // StdSql encompasses the standard methods of the *sql.DB type, and other types that
70
+ // wrap these methods.
71
+ type StdSql interface {
72
+ Query(string, ...interface{}) (*sql.Rows, error)
73
+ QueryRow(string, ...interface{}) *sql.Row
74
+ Exec(string, ...interface{}) (sql.Result, error)
75
+ }
76
+
77
+ type stdsqlRunner struct {
78
+ StdSql
79
+ }
80
+
81
+ func (r *stdsqlRunner) QueryRow(query string, args ...interface{}) RowScanner {
82
+ return r.StdSql.QueryRow(query, args...)
83
+ }
84
+
85
+ func setRunWith(b interface{}, runner BaseRunner) interface{} {
86
+ switch r := runner.(type) {
87
+ case StdSqlCtx:
88
+ runner = WrapStdSqlCtx(r)
89
+ case StdSql:
90
+ runner = WrapStdSql(r)
91
+ }
92
+ return builder.Set(b, "RunWith", runner)
93
+ }
94
+
95
+ // RunnerNotSet is returned by methods that need a Runner if it isn't set.
96
+ var RunnerNotSet = fmt.Errorf("cannot run; no Runner set (RunWith)")
97
+
98
+ // RunnerNotQueryRunner is returned by QueryRow if the RunWith value doesn't implement QueryRower.
99
+ var RunnerNotQueryRunner = fmt.Errorf("cannot QueryRow; Runner is not a QueryRower")
100
+
101
+ // ExecWith Execs the SQL returned by s with db.
102
+ func ExecWith(db Execer, s Sqlizer) (res sql.Result, err error) {
103
+ query, args, err := s.ToSql()
104
+ if err != nil {
105
+ return
106
+ }
107
+ return db.Exec(query, args...)
108
+ }
109
+
110
+ // QueryWith Querys the SQL returned by s with db.
111
+ func QueryWith(db Queryer, s Sqlizer) (rows *sql.Rows, err error) {
112
+ query, args, err := s.ToSql()
113
+ if err != nil {
114
+ return
115
+ }
116
+ return db.Query(query, args...)
117
+ }
118
+
119
+ // QueryRowWith QueryRows the SQL returned by s with db.
120
+ func QueryRowWith(db QueryRower, s Sqlizer) RowScanner {
121
+ query, args, err := s.ToSql()
122
+ return &Row{RowScanner: db.QueryRow(query, args...), err: err}
123
+ }
124
+
125
+ // DebugSqlizer calls ToSql on s and shows the approximate SQL to be executed
126
+ //
127
+ // If ToSql returns an error, the result of this method will look like:
128
+ // "[ToSql error: %s]" or "[DebugSqlizer error: %s]"
129
+ //
130
+ // IMPORTANT: As its name suggests, this function should only be used for
131
+ // debugging. While the string result *might* be valid SQL, this function does
132
+ // not try very hard to ensure it. Additionally, executing the output of this
133
+ // function with any untrusted user input is certainly insecure.
134
+ func DebugSqlizer(s Sqlizer) string {
135
+ sql, args, err := s.ToSql()
136
+ if err != nil {
137
+ return fmt.Sprintf("[ToSql error: %s]", err)
138
+ }
139
+
140
+ var placeholder string
141
+ downCast, ok := s.(placeholderDebugger)
142
+ if !ok {
143
+ placeholder = "?"
144
+ } else {
145
+ placeholder = downCast.debugPlaceholder()
146
+ }
147
+ // TODO: dedupe this with placeholder.go
148
+ buf := &bytes.Buffer{}
149
+ i := 0
150
+ for {
151
+ p := strings.Index(sql, placeholder)
152
+ if p == -1 {
153
+ break
154
+ }
155
+ if len(sql[p:]) > 1 && sql[p:p+2] == "??" { // escape ?? => ?
156
+ buf.WriteString(sql[:p])
157
+ buf.WriteString("?")
158
+ if len(sql[p:]) == 1 {
159
+ break
160
+ }
161
+ sql = sql[p+2:]
162
+ } else {
163
+ if i+1 > len(args) {
164
+ return fmt.Sprintf(
165
+ "[DebugSqlizer error: too many placeholders in %#v for %d args]",
166
+ sql, len(args))
167
+ }
168
+ buf.WriteString(sql[:p])
169
+ fmt.Fprintf(buf, "'%v'", args[i])
170
+ // advance our sql string "cursor" beyond the arg we placed
171
+ sql = sql[p+1:]
172
+ i++
173
+ }
174
+ }
175
+ if i < len(args) {
176
+ return fmt.Sprintf(
177
+ "[DebugSqlizer error: not enough placeholders in %#v for %d args]",
178
+ sql, len(args))
179
+ }
180
+ // "append" any remaning sql that won't need interpolating
181
+ buf.WriteString(sql)
182
+ return buf.String()
183
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/squirrel_ctx.go ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+ "errors"
9
+ )
10
+
11
+ // NoContextSupport is returned if a db doesn't support Context.
12
+ var NoContextSupport = errors.New("DB does not support Context")
13
+
14
+ // ExecerContext is the interface that wraps the ExecContext method.
15
+ //
16
+ // Exec executes the given query as implemented by database/sql.ExecContext.
17
+ type ExecerContext interface {
18
+ ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
19
+ }
20
+
21
+ // QueryerContext is the interface that wraps the QueryContext method.
22
+ //
23
+ // QueryContext executes the given query as implemented by database/sql.QueryContext.
24
+ type QueryerContext interface {
25
+ QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
26
+ }
27
+
28
+ // QueryRowerContext is the interface that wraps the QueryRowContext method.
29
+ //
30
+ // QueryRowContext executes the given query as implemented by database/sql.QueryRowContext.
31
+ type QueryRowerContext interface {
32
+ QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner
33
+ }
34
+
35
+ // RunnerContext groups the Runner interface, along with the Context versions of each of
36
+ // its methods
37
+ type RunnerContext interface {
38
+ Runner
39
+ QueryerContext
40
+ QueryRowerContext
41
+ ExecerContext
42
+ }
43
+
44
+ // WrapStdSqlCtx wraps a type implementing the standard SQL interface plus the context
45
+ // versions of the methods with methods that squirrel expects.
46
+ func WrapStdSqlCtx(stdSqlCtx StdSqlCtx) RunnerContext {
47
+ return &stdsqlCtxRunner{stdSqlCtx}
48
+ }
49
+
50
+ // StdSqlCtx encompasses the standard methods of the *sql.DB type, along with the Context
51
+ // versions of those methods, and other types that wrap these methods.
52
+ type StdSqlCtx interface {
53
+ StdSql
54
+ QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
55
+ QueryRowContext(context.Context, string, ...interface{}) *sql.Row
56
+ ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
57
+ }
58
+
59
+ type stdsqlCtxRunner struct {
60
+ StdSqlCtx
61
+ }
62
+
63
+ func (r *stdsqlCtxRunner) QueryRow(query string, args ...interface{}) RowScanner {
64
+ return r.StdSqlCtx.QueryRow(query, args...)
65
+ }
66
+
67
+ func (r *stdsqlCtxRunner) QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner {
68
+ return r.StdSqlCtx.QueryRowContext(ctx, query, args...)
69
+ }
70
+
71
+ // ExecContextWith ExecContexts the SQL returned by s with db.
72
+ func ExecContextWith(ctx context.Context, db ExecerContext, s Sqlizer) (res sql.Result, err error) {
73
+ query, args, err := s.ToSql()
74
+ if err != nil {
75
+ return
76
+ }
77
+ return db.ExecContext(ctx, query, args...)
78
+ }
79
+
80
+ // QueryContextWith QueryContexts the SQL returned by s with db.
81
+ func QueryContextWith(ctx context.Context, db QueryerContext, s Sqlizer) (rows *sql.Rows, err error) {
82
+ query, args, err := s.ToSql()
83
+ if err != nil {
84
+ return
85
+ }
86
+ return db.QueryContext(ctx, query, args...)
87
+ }
88
+
89
+ // QueryRowContextWith QueryRowContexts the SQL returned by s with db.
90
+ func QueryRowContextWith(ctx context.Context, db QueryRowerContext, s Sqlizer) RowScanner {
91
+ query, args, err := s.ToSql()
92
+ return &Row{RowScanner: db.QueryRowContext(ctx, query, args...), err: err}
93
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/statement.go ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import "github.com/lann/builder"
4
+
5
+ // StatementBuilderType is the type of StatementBuilder.
6
+ type StatementBuilderType builder.Builder
7
+
8
+ // Select returns a SelectBuilder for this StatementBuilderType.
9
+ func (b StatementBuilderType) Select(columns ...string) SelectBuilder {
10
+ return SelectBuilder(b).Columns(columns...)
11
+ }
12
+
13
+ // Insert returns a InsertBuilder for this StatementBuilderType.
14
+ func (b StatementBuilderType) Insert(into string) InsertBuilder {
15
+ return InsertBuilder(b).Into(into)
16
+ }
17
+
18
+ // Replace returns a InsertBuilder for this StatementBuilderType with the
19
+ // statement keyword set to "REPLACE".
20
+ func (b StatementBuilderType) Replace(into string) InsertBuilder {
21
+ return InsertBuilder(b).statementKeyword("REPLACE").Into(into)
22
+ }
23
+
24
+ // Update returns a UpdateBuilder for this StatementBuilderType.
25
+ func (b StatementBuilderType) Update(table string) UpdateBuilder {
26
+ return UpdateBuilder(b).Table(table)
27
+ }
28
+
29
+ // Delete returns a DeleteBuilder for this StatementBuilderType.
30
+ func (b StatementBuilderType) Delete(from string) DeleteBuilder {
31
+ return DeleteBuilder(b).From(from)
32
+ }
33
+
34
+ // PlaceholderFormat sets the PlaceholderFormat field for any child builders.
35
+ func (b StatementBuilderType) PlaceholderFormat(f PlaceholderFormat) StatementBuilderType {
36
+ return builder.Set(b, "PlaceholderFormat", f).(StatementBuilderType)
37
+ }
38
+
39
+ // RunWith sets the RunWith field for any child builders.
40
+ func (b StatementBuilderType) RunWith(runner BaseRunner) StatementBuilderType {
41
+ return setRunWith(b, runner).(StatementBuilderType)
42
+ }
43
+
44
+ // Where adds WHERE expressions to the query.
45
+ //
46
+ // See SelectBuilder.Where for more information.
47
+ func (b StatementBuilderType) Where(pred interface{}, args ...interface{}) StatementBuilderType {
48
+ return builder.Append(b, "WhereParts", newWherePart(pred, args...)).(StatementBuilderType)
49
+ }
50
+
51
+ // StatementBuilder is a parent builder for other builders, e.g. SelectBuilder.
52
+ var StatementBuilder = StatementBuilderType(builder.EmptyBuilder).PlaceholderFormat(Question)
53
+
54
+ // Select returns a new SelectBuilder, optionally setting some result columns.
55
+ //
56
+ // See SelectBuilder.Columns.
57
+ func Select(columns ...string) SelectBuilder {
58
+ return StatementBuilder.Select(columns...)
59
+ }
60
+
61
+ // Insert returns a new InsertBuilder with the given table name.
62
+ //
63
+ // See InsertBuilder.Into.
64
+ func Insert(into string) InsertBuilder {
65
+ return StatementBuilder.Insert(into)
66
+ }
67
+
68
+ // Replace returns a new InsertBuilder with the statement keyword set to
69
+ // "REPLACE" and with the given table name.
70
+ //
71
+ // See InsertBuilder.Into.
72
+ func Replace(into string) InsertBuilder {
73
+ return StatementBuilder.Replace(into)
74
+ }
75
+
76
+ // Update returns a new UpdateBuilder with the given table name.
77
+ //
78
+ // See UpdateBuilder.Table.
79
+ func Update(table string) UpdateBuilder {
80
+ return StatementBuilder.Update(table)
81
+ }
82
+
83
+ // Delete returns a new DeleteBuilder with the given table name.
84
+ //
85
+ // See DeleteBuilder.Table.
86
+ func Delete(from string) DeleteBuilder {
87
+ return StatementBuilder.Delete(from)
88
+ }
89
+
90
+ // Case returns a new CaseBuilder
91
+ // "what" represents case value
92
+ func Case(what ...interface{}) CaseBuilder {
93
+ b := CaseBuilder(builder.EmptyBuilder)
94
+
95
+ switch len(what) {
96
+ case 0:
97
+ case 1:
98
+ b = b.what(what[0])
99
+ default:
100
+ b = b.what(newPart(what[0], what[1:]...))
101
+
102
+ }
103
+ return b
104
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher.go ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "database/sql"
5
+ "fmt"
6
+ "sync"
7
+ )
8
+
9
+ // Prepareer is the interface that wraps the Prepare method.
10
+ //
11
+ // Prepare executes the given query as implemented by database/sql.Prepare.
12
+ type Preparer interface {
13
+ Prepare(query string) (*sql.Stmt, error)
14
+ }
15
+
16
+ // DBProxy groups the Execer, Queryer, QueryRower, and Preparer interfaces.
17
+ type DBProxy interface {
18
+ Execer
19
+ Queryer
20
+ QueryRower
21
+ Preparer
22
+ }
23
+
24
+ // NOTE: NewStmtCache is defined in stmtcacher_ctx.go (Go >= 1.8) or stmtcacher_noctx.go (Go < 1.8).
25
+
26
+ // StmtCache wraps and delegates down to a Preparer type
27
+ //
28
+ // It also automatically prepares all statements sent to the underlying Preparer calls
29
+ // for Exec, Query and QueryRow and caches the returns *sql.Stmt using the provided
30
+ // query as the key. So that it can be automatically re-used.
31
+ type StmtCache struct {
32
+ prep Preparer
33
+ cache map[string]*sql.Stmt
34
+ mu sync.Mutex
35
+ }
36
+
37
+ // Prepare delegates down to the underlying Preparer and caches the result
38
+ // using the provided query as a key
39
+ func (sc *StmtCache) Prepare(query string) (*sql.Stmt, error) {
40
+ sc.mu.Lock()
41
+ defer sc.mu.Unlock()
42
+
43
+ stmt, ok := sc.cache[query]
44
+ if ok {
45
+ return stmt, nil
46
+ }
47
+ stmt, err := sc.prep.Prepare(query)
48
+ if err == nil {
49
+ sc.cache[query] = stmt
50
+ }
51
+ return stmt, err
52
+ }
53
+
54
+ // Exec delegates down to the underlying Preparer using a prepared statement
55
+ func (sc *StmtCache) Exec(query string, args ...interface{}) (res sql.Result, err error) {
56
+ stmt, err := sc.Prepare(query)
57
+ if err != nil {
58
+ return
59
+ }
60
+ return stmt.Exec(args...)
61
+ }
62
+
63
+ // Query delegates down to the underlying Preparer using a prepared statement
64
+ func (sc *StmtCache) Query(query string, args ...interface{}) (rows *sql.Rows, err error) {
65
+ stmt, err := sc.Prepare(query)
66
+ if err != nil {
67
+ return
68
+ }
69
+ return stmt.Query(args...)
70
+ }
71
+
72
+ // QueryRow delegates down to the underlying Preparer using a prepared statement
73
+ func (sc *StmtCache) QueryRow(query string, args ...interface{}) RowScanner {
74
+ stmt, err := sc.Prepare(query)
75
+ if err != nil {
76
+ return &Row{err: err}
77
+ }
78
+ return stmt.QueryRow(args...)
79
+ }
80
+
81
+ // Clear removes and closes all the currently cached prepared statements
82
+ func (sc *StmtCache) Clear() (err error) {
83
+ sc.mu.Lock()
84
+ defer sc.mu.Unlock()
85
+
86
+ for key, stmt := range sc.cache {
87
+ delete(sc.cache, key)
88
+
89
+ if stmt == nil {
90
+ continue
91
+ }
92
+
93
+ if cerr := stmt.Close(); cerr != nil {
94
+ err = cerr
95
+ }
96
+ }
97
+
98
+ if err != nil {
99
+ return fmt.Errorf("one or more Stmt.Close failed; last error: %v", err)
100
+ }
101
+
102
+ return
103
+ }
104
+
105
+ type DBProxyBeginner interface {
106
+ DBProxy
107
+ Begin() (*sql.Tx, error)
108
+ }
109
+
110
+ type stmtCacheProxy struct {
111
+ DBProxy
112
+ db *sql.DB
113
+ }
114
+
115
+ func NewStmtCacheProxy(db *sql.DB) DBProxyBeginner {
116
+ return &stmtCacheProxy{DBProxy: NewStmtCache(db), db: db}
117
+ }
118
+
119
+ func (sp *stmtCacheProxy) Begin() (*sql.Tx, error) {
120
+ return sp.db.Begin()
121
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher_ctx.go ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+ )
9
+
10
+ // PrepareerContext is the interface that wraps the Prepare and PrepareContext methods.
11
+ //
12
+ // Prepare executes the given query as implemented by database/sql.Prepare.
13
+ // PrepareContext executes the given query as implemented by database/sql.PrepareContext.
14
+ type PreparerContext interface {
15
+ Preparer
16
+ PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
17
+ }
18
+
19
+ // DBProxyContext groups the Execer, Queryer, QueryRower and PreparerContext interfaces.
20
+ type DBProxyContext interface {
21
+ Execer
22
+ Queryer
23
+ QueryRower
24
+ PreparerContext
25
+ }
26
+
27
+ // NewStmtCache returns a *StmtCache wrapping a PreparerContext that caches Prepared Stmts.
28
+ //
29
+ // Stmts are cached based on the string value of their queries.
30
+ func NewStmtCache(prep PreparerContext) *StmtCache {
31
+ return &StmtCache{prep: prep, cache: make(map[string]*sql.Stmt)}
32
+ }
33
+
34
+ // NewStmtCacher is deprecated
35
+ //
36
+ // Use NewStmtCache instead
37
+ func NewStmtCacher(prep PreparerContext) DBProxyContext {
38
+ return NewStmtCache(prep)
39
+ }
40
+
41
+ // PrepareContext delegates down to the underlying PreparerContext and caches the result
42
+ // using the provided query as a key
43
+ func (sc *StmtCache) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) {
44
+ ctxPrep, ok := sc.prep.(PreparerContext)
45
+ if !ok {
46
+ return nil, NoContextSupport
47
+ }
48
+ sc.mu.Lock()
49
+ defer sc.mu.Unlock()
50
+ stmt, ok := sc.cache[query]
51
+ if ok {
52
+ return stmt, nil
53
+ }
54
+ stmt, err := ctxPrep.PrepareContext(ctx, query)
55
+ if err == nil {
56
+ sc.cache[query] = stmt
57
+ }
58
+ return stmt, err
59
+ }
60
+
61
+ // ExecContext delegates down to the underlying PreparerContext using a prepared statement
62
+ func (sc *StmtCache) ExecContext(ctx context.Context, query string, args ...interface{}) (res sql.Result, err error) {
63
+ stmt, err := sc.PrepareContext(ctx, query)
64
+ if err != nil {
65
+ return
66
+ }
67
+ return stmt.ExecContext(ctx, args...)
68
+ }
69
+
70
+ // QueryContext delegates down to the underlying PreparerContext using a prepared statement
71
+ func (sc *StmtCache) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error) {
72
+ stmt, err := sc.PrepareContext(ctx, query)
73
+ if err != nil {
74
+ return
75
+ }
76
+ return stmt.QueryContext(ctx, args...)
77
+ }
78
+
79
+ // QueryRowContext delegates down to the underlying PreparerContext using a prepared statement
80
+ func (sc *StmtCache) QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner {
81
+ stmt, err := sc.PrepareContext(ctx, query)
82
+ if err != nil {
83
+ return &Row{err: err}
84
+ }
85
+ return stmt.QueryRowContext(ctx, args...)
86
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/stmtcacher_noctx.go ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build !go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "database/sql"
7
+ )
8
+
9
+ // NewStmtCacher returns a DBProxy wrapping prep that caches Prepared Stmts.
10
+ //
11
+ // Stmts are cached based on the string value of their queries.
12
+ func NewStmtCache(prep Preparer) *StmtCache {
13
+ return &StmtCacher{prep: prep, cache: make(map[string]*sql.Stmt)}
14
+ }
15
+
16
+ // NewStmtCacher is deprecated
17
+ //
18
+ // Use NewStmtCache instead
19
+ func NewStmtCacher(prep Preparer) DBProxy {
20
+ return NewStmtCache(prep)
21
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/update.go ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "bytes"
5
+ "database/sql"
6
+ "fmt"
7
+ "sort"
8
+ "strings"
9
+
10
+ "github.com/lann/builder"
11
+ )
12
+
13
+ type updateData struct {
14
+ PlaceholderFormat PlaceholderFormat
15
+ RunWith BaseRunner
16
+ Prefixes []Sqlizer
17
+ Table string
18
+ SetClauses []setClause
19
+ From Sqlizer
20
+ WhereParts []Sqlizer
21
+ OrderBys []string
22
+ Limit string
23
+ Offset string
24
+ Suffixes []Sqlizer
25
+ }
26
+
27
+ type setClause struct {
28
+ column string
29
+ value interface{}
30
+ }
31
+
32
+ func (d *updateData) Exec() (sql.Result, error) {
33
+ if d.RunWith == nil {
34
+ return nil, RunnerNotSet
35
+ }
36
+ return ExecWith(d.RunWith, d)
37
+ }
38
+
39
+ func (d *updateData) Query() (*sql.Rows, error) {
40
+ if d.RunWith == nil {
41
+ return nil, RunnerNotSet
42
+ }
43
+ return QueryWith(d.RunWith, d)
44
+ }
45
+
46
+ func (d *updateData) QueryRow() RowScanner {
47
+ if d.RunWith == nil {
48
+ return &Row{err: RunnerNotSet}
49
+ }
50
+ queryRower, ok := d.RunWith.(QueryRower)
51
+ if !ok {
52
+ return &Row{err: RunnerNotQueryRunner}
53
+ }
54
+ return QueryRowWith(queryRower, d)
55
+ }
56
+
57
+ func (d *updateData) ToSql() (sqlStr string, args []interface{}, err error) {
58
+ if len(d.Table) == 0 {
59
+ err = fmt.Errorf("update statements must specify a table")
60
+ return
61
+ }
62
+ if len(d.SetClauses) == 0 {
63
+ err = fmt.Errorf("update statements must have at least one Set clause")
64
+ return
65
+ }
66
+
67
+ sql := &bytes.Buffer{}
68
+
69
+ if len(d.Prefixes) > 0 {
70
+ args, err = appendToSql(d.Prefixes, sql, " ", args)
71
+ if err != nil {
72
+ return
73
+ }
74
+
75
+ sql.WriteString(" ")
76
+ }
77
+
78
+ sql.WriteString("UPDATE ")
79
+ sql.WriteString(d.Table)
80
+
81
+ sql.WriteString(" SET ")
82
+ setSqls := make([]string, len(d.SetClauses))
83
+ for i, setClause := range d.SetClauses {
84
+ var valSql string
85
+ if vs, ok := setClause.value.(Sqlizer); ok {
86
+ vsql, vargs, err := vs.ToSql()
87
+ if err != nil {
88
+ return "", nil, err
89
+ }
90
+ if _, ok := vs.(SelectBuilder); ok {
91
+ valSql = vsql
92
+ } else {
93
+ valSql = fmt.Sprintf("(%s)", vsql)
94
+ }
95
+ args = append(args, vargs...)
96
+ } else {
97
+ valSql = "?"
98
+ args = append(args, setClause.value)
99
+ }
100
+ setSqls[i] = fmt.Sprintf("%s = %s", setClause.column, valSql)
101
+ }
102
+ sql.WriteString(strings.Join(setSqls, ", "))
103
+
104
+ if d.From != nil {
105
+ sql.WriteString(" FROM ")
106
+ args, err = appendToSql([]Sqlizer{d.From}, sql, "", args)
107
+ if err != nil {
108
+ return
109
+ }
110
+ }
111
+
112
+ if len(d.WhereParts) > 0 {
113
+ sql.WriteString(" WHERE ")
114
+ args, err = appendToSql(d.WhereParts, sql, " AND ", args)
115
+ if err != nil {
116
+ return
117
+ }
118
+ }
119
+
120
+ if len(d.OrderBys) > 0 {
121
+ sql.WriteString(" ORDER BY ")
122
+ sql.WriteString(strings.Join(d.OrderBys, ", "))
123
+ }
124
+
125
+ if len(d.Limit) > 0 {
126
+ sql.WriteString(" LIMIT ")
127
+ sql.WriteString(d.Limit)
128
+ }
129
+
130
+ if len(d.Offset) > 0 {
131
+ sql.WriteString(" OFFSET ")
132
+ sql.WriteString(d.Offset)
133
+ }
134
+
135
+ if len(d.Suffixes) > 0 {
136
+ sql.WriteString(" ")
137
+ args, err = appendToSql(d.Suffixes, sql, " ", args)
138
+ if err != nil {
139
+ return
140
+ }
141
+ }
142
+
143
+ sqlStr, err = d.PlaceholderFormat.ReplacePlaceholders(sql.String())
144
+ return
145
+ }
146
+
147
+ // Builder
148
+
149
+ // UpdateBuilder builds SQL UPDATE statements.
150
+ type UpdateBuilder builder.Builder
151
+
152
+ func init() {
153
+ builder.Register(UpdateBuilder{}, updateData{})
154
+ }
155
+
156
+ // Format methods
157
+
158
+ // PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the
159
+ // query.
160
+ func (b UpdateBuilder) PlaceholderFormat(f PlaceholderFormat) UpdateBuilder {
161
+ return builder.Set(b, "PlaceholderFormat", f).(UpdateBuilder)
162
+ }
163
+
164
+ // Runner methods
165
+
166
+ // RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.
167
+ func (b UpdateBuilder) RunWith(runner BaseRunner) UpdateBuilder {
168
+ return setRunWith(b, runner).(UpdateBuilder)
169
+ }
170
+
171
+ // Exec builds and Execs the query with the Runner set by RunWith.
172
+ func (b UpdateBuilder) Exec() (sql.Result, error) {
173
+ data := builder.GetStruct(b).(updateData)
174
+ return data.Exec()
175
+ }
176
+
177
+ func (b UpdateBuilder) Query() (*sql.Rows, error) {
178
+ data := builder.GetStruct(b).(updateData)
179
+ return data.Query()
180
+ }
181
+
182
+ func (b UpdateBuilder) QueryRow() RowScanner {
183
+ data := builder.GetStruct(b).(updateData)
184
+ return data.QueryRow()
185
+ }
186
+
187
+ func (b UpdateBuilder) Scan(dest ...interface{}) error {
188
+ return b.QueryRow().Scan(dest...)
189
+ }
190
+
191
+ // SQL methods
192
+
193
+ // ToSql builds the query into a SQL string and bound args.
194
+ func (b UpdateBuilder) ToSql() (string, []interface{}, error) {
195
+ data := builder.GetStruct(b).(updateData)
196
+ return data.ToSql()
197
+ }
198
+
199
+ // MustSql builds the query into a SQL string and bound args.
200
+ // It panics if there are any errors.
201
+ func (b UpdateBuilder) MustSql() (string, []interface{}) {
202
+ sql, args, err := b.ToSql()
203
+ if err != nil {
204
+ panic(err)
205
+ }
206
+ return sql, args
207
+ }
208
+
209
+ // Prefix adds an expression to the beginning of the query
210
+ func (b UpdateBuilder) Prefix(sql string, args ...interface{}) UpdateBuilder {
211
+ return b.PrefixExpr(Expr(sql, args...))
212
+ }
213
+
214
+ // PrefixExpr adds an expression to the very beginning of the query
215
+ func (b UpdateBuilder) PrefixExpr(expr Sqlizer) UpdateBuilder {
216
+ return builder.Append(b, "Prefixes", expr).(UpdateBuilder)
217
+ }
218
+
219
+ // Table sets the table to be updated.
220
+ func (b UpdateBuilder) Table(table string) UpdateBuilder {
221
+ return builder.Set(b, "Table", table).(UpdateBuilder)
222
+ }
223
+
224
+ // Set adds SET clauses to the query.
225
+ func (b UpdateBuilder) Set(column string, value interface{}) UpdateBuilder {
226
+ return builder.Append(b, "SetClauses", setClause{column: column, value: value}).(UpdateBuilder)
227
+ }
228
+
229
+ // SetMap is a convenience method which calls .Set for each key/value pair in clauses.
230
+ func (b UpdateBuilder) SetMap(clauses map[string]interface{}) UpdateBuilder {
231
+ keys := make([]string, len(clauses))
232
+ i := 0
233
+ for key := range clauses {
234
+ keys[i] = key
235
+ i++
236
+ }
237
+ sort.Strings(keys)
238
+ for _, key := range keys {
239
+ val, _ := clauses[key]
240
+ b = b.Set(key, val)
241
+ }
242
+ return b
243
+ }
244
+
245
+ // From adds FROM clause to the query
246
+ // FROM is valid construct in postgresql only.
247
+ func (b UpdateBuilder) From(from string) UpdateBuilder {
248
+ return builder.Set(b, "From", newPart(from)).(UpdateBuilder)
249
+ }
250
+
251
+ // FromSelect sets a subquery into the FROM clause of the query.
252
+ func (b UpdateBuilder) FromSelect(from SelectBuilder, alias string) UpdateBuilder {
253
+ // Prevent misnumbered parameters in nested selects (#183).
254
+ from = from.PlaceholderFormat(Question)
255
+ return builder.Set(b, "From", Alias(from, alias)).(UpdateBuilder)
256
+ }
257
+
258
+ // Where adds WHERE expressions to the query.
259
+ //
260
+ // See SelectBuilder.Where for more information.
261
+ func (b UpdateBuilder) Where(pred interface{}, args ...interface{}) UpdateBuilder {
262
+ return builder.Append(b, "WhereParts", newWherePart(pred, args...)).(UpdateBuilder)
263
+ }
264
+
265
+ // OrderBy adds ORDER BY expressions to the query.
266
+ func (b UpdateBuilder) OrderBy(orderBys ...string) UpdateBuilder {
267
+ return builder.Extend(b, "OrderBys", orderBys).(UpdateBuilder)
268
+ }
269
+
270
+ // Limit sets a LIMIT clause on the query.
271
+ func (b UpdateBuilder) Limit(limit uint64) UpdateBuilder {
272
+ return builder.Set(b, "Limit", fmt.Sprintf("%d", limit)).(UpdateBuilder)
273
+ }
274
+
275
+ // Offset sets a OFFSET clause on the query.
276
+ func (b UpdateBuilder) Offset(offset uint64) UpdateBuilder {
277
+ return builder.Set(b, "Offset", fmt.Sprintf("%d", offset)).(UpdateBuilder)
278
+ }
279
+
280
+ // Suffix adds an expression to the end of the query
281
+ func (b UpdateBuilder) Suffix(sql string, args ...interface{}) UpdateBuilder {
282
+ return b.SuffixExpr(Expr(sql, args...))
283
+ }
284
+
285
+ // SuffixExpr adds an expression to the end of the query
286
+ func (b UpdateBuilder) SuffixExpr(expr Sqlizer) UpdateBuilder {
287
+ return builder.Append(b, "Suffixes", expr).(UpdateBuilder)
288
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/update_ctx.go ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "context"
7
+ "database/sql"
8
+
9
+ "github.com/lann/builder"
10
+ )
11
+
12
+ func (d *updateData) ExecContext(ctx context.Context) (sql.Result, error) {
13
+ if d.RunWith == nil {
14
+ return nil, RunnerNotSet
15
+ }
16
+ ctxRunner, ok := d.RunWith.(ExecerContext)
17
+ if !ok {
18
+ return nil, NoContextSupport
19
+ }
20
+ return ExecContextWith(ctx, ctxRunner, d)
21
+ }
22
+
23
+ func (d *updateData) QueryContext(ctx context.Context) (*sql.Rows, error) {
24
+ if d.RunWith == nil {
25
+ return nil, RunnerNotSet
26
+ }
27
+ ctxRunner, ok := d.RunWith.(QueryerContext)
28
+ if !ok {
29
+ return nil, NoContextSupport
30
+ }
31
+ return QueryContextWith(ctx, ctxRunner, d)
32
+ }
33
+
34
+ func (d *updateData) QueryRowContext(ctx context.Context) RowScanner {
35
+ if d.RunWith == nil {
36
+ return &Row{err: RunnerNotSet}
37
+ }
38
+ queryRower, ok := d.RunWith.(QueryRowerContext)
39
+ if !ok {
40
+ if _, ok := d.RunWith.(QueryerContext); !ok {
41
+ return &Row{err: RunnerNotQueryRunner}
42
+ }
43
+ return &Row{err: NoContextSupport}
44
+ }
45
+ return QueryRowContextWith(ctx, queryRower, d)
46
+ }
47
+
48
+ // ExecContext builds and ExecContexts the query with the Runner set by RunWith.
49
+ func (b UpdateBuilder) ExecContext(ctx context.Context) (sql.Result, error) {
50
+ data := builder.GetStruct(b).(updateData)
51
+ return data.ExecContext(ctx)
52
+ }
53
+
54
+ // QueryContext builds and QueryContexts the query with the Runner set by RunWith.
55
+ func (b UpdateBuilder) QueryContext(ctx context.Context) (*sql.Rows, error) {
56
+ data := builder.GetStruct(b).(updateData)
57
+ return data.QueryContext(ctx)
58
+ }
59
+
60
+ // QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.
61
+ func (b UpdateBuilder) QueryRowContext(ctx context.Context) RowScanner {
62
+ data := builder.GetStruct(b).(updateData)
63
+ return data.QueryRowContext(ctx)
64
+ }
65
+
66
+ // ScanContext is a shortcut for QueryRowContext().Scan.
67
+ func (b UpdateBuilder) ScanContext(ctx context.Context, dest ...interface{}) error {
68
+ return b.QueryRowContext(ctx).Scan(dest...)
69
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/environment/source/where.go ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "fmt"
5
+ )
6
+
7
+ type wherePart part
8
+
9
+ func newWherePart(pred interface{}, args ...interface{}) Sqlizer {
10
+ return &wherePart{pred: pred, args: args}
11
+ }
12
+
13
+ func (p wherePart) ToSql() (sql string, args []interface{}, err error) {
14
+ switch pred := p.pred.(type) {
15
+ case nil:
16
+ // no-op
17
+ case rawSqlizer:
18
+ return pred.toSqlRaw()
19
+ case Sqlizer:
20
+ return pred.ToSql()
21
+ case map[string]interface{}:
22
+ return Eq(pred).ToSql()
23
+ case string:
24
+ sql = pred
25
+ args = p.args
26
+ default:
27
+ err = fmt.Errorf("expected string-keyed map or string, not %T", pred)
28
+ }
29
+ return
30
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/instruction.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ UPDATE query generates incorrect SQL with subqueries and expressions
2
+
3
+ When using UPDATE queries with subqueries or complex expressions, the generated SQL wraps all values in parentheses incorrectly. This causes subqueries to lose their required parentheses while simple expressions get unnecessary ones.
4
+
5
+ #### Steps to Reproduce
6
+
7
+ ```go
8
+ package main
9
+
10
+ import (
11
+ "fmt"
12
+ "github.com/Masterminds/squirrel"
13
+ )
14
+
15
+ func main() {
16
+ // This should generate: UPDATE a SET c3 = (SELECT a FROM b)
17
+ // But actually generates: UPDATE a SET c3 = SELECT a FROM b
18
+ subquery := squirrel.Select("a").From("b")
19
+
20
+ update := squirrel.Update("a").
21
+ Set("c3", subquery)
22
+
23
+ sql, args, err := update.ToSql()
24
+ if err != nil {
25
+ panic(err)
26
+ }
27
+
28
+ fmt.Printf("Generated SQL: %s\n", sql)
29
+ fmt.Printf("Args: %v\n", args)
30
+
31
+ // Also affects expressions - they get wrapped when they shouldn't be
32
+ update2 := squirrel.Update("a").
33
+ Set("b", squirrel.Expr("? + 1", 5))
34
+
35
+ sql2, args2, err2 := update2.ToSql()
36
+ if err2 != nil {
37
+ panic(err2)
38
+ }
39
+
40
+ fmt.Printf("Expression SQL: %s\n", sql2)
41
+ fmt.Printf("Expression Args: %v\n", args2)
42
+ }
43
+ ```
44
+
45
+ The subquery loses its required parentheses making it invalid SQL, while expressions get unnecessary parentheses.
46
+ Work in /testbed. This is a broken source-only export without Git history or tests. Grading restores frozen private tests independently. Repair existing implementation files; new arbitrary files are outside the current transfer contract. Offline Go dependencies are preinstalled.
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/provenance.json ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cloud_launch_ready": false,
3
+ "execution_command": [
4
+ "/usr/local/go/bin/go",
5
+ "test",
6
+ "-json",
7
+ "-count=1",
8
+ "./..."
9
+ ],
10
+ "execution_profile": "harbor-semantic-jobs-v1",
11
+ "full_rfc008": false,
12
+ "generated_reference": false,
13
+ "native_validation_performed": false,
14
+ "negative_classes": {
15
+ "delete-tests": "same wrong implementation with verifier deletion/stdout spoof attempt",
16
+ "original-bug": "task-specific unchanged semantic bug",
17
+ "stale-reward": "same wrong implementation with stale reward spoof attempt"
18
+ },
19
+ "new_arbitrary_files_supported": false,
20
+ "partial_hunk_control": {
21
+ "basis": "single-hunk original-bug canary is NOP-equivalent; other canaries test abuse classes only",
22
+ "extra_semantic_repair_coverage": false,
23
+ "original_patch_hunks": 1
24
+ },
25
+ "private_frozen_files": {
26
+ "case_test.go": {
27
+ "mode": "0o644",
28
+ "sha256": "fdb8c60761dc1ab02953e86f1736bd29e644e61bb7f67a394a5f71d276a67298",
29
+ "size": 3296
30
+ },
31
+ "delete_ctx_test.go": {
32
+ "mode": "0o644",
33
+ "sha256": "07e5cd531fbc380655a6f441eeee23da925195d67a1a7e7682785806af51014e",
34
+ "size": 847
35
+ },
36
+ "delete_test.go": {
37
+ "mode": "0o644",
38
+ "sha256": "44ac247a59eb89cd5f41e3f0948a78e51e757d0888a72874d12a12c6db1acfb0",
39
+ "size": 1806
40
+ },
41
+ "expr_test.go": {
42
+ "mode": "0o644",
43
+ "sha256": "ab52b68e40a81bda968dacc733f34c08626f299405450c383daf438e33897a65",
44
+ "size": 10245
45
+ },
46
+ "insert_ctx_test.go": {
47
+ "mode": "0o644",
48
+ "sha256": "b3e3efaf75fee82c147958afb70a90334f4f08cf29b64bd76d23a03b9824f299",
49
+ "size": 807
50
+ },
51
+ "insert_test.go": {
52
+ "mode": "0o644",
53
+ "sha256": "665fe6694c9ce48b2bcbdfd34ab9bde67d8fd7601b3d5798f4dacd693e1da278",
54
+ "size": 2627
55
+ },
56
+ "integration/integration_test.go": {
57
+ "mode": "0o644",
58
+ "sha256": "c8631b72fa30417861d7ba87a1a9a5c0883d01744fb49bf779360dc4a61b9abf",
59
+ "size": 3162
60
+ },
61
+ "placeholder_test.go": {
62
+ "mode": "0o644",
63
+ "sha256": "c498900e8f98d981e90863f0603d19c11db17e786eae008bdc5af2b25ae8eb13",
64
+ "size": 2005
65
+ },
66
+ "row_test.go": {
67
+ "mode": "0o644",
68
+ "sha256": "7fe834ce33424df8e009fa44ee5acea25508c7e439d1bf07fddf6d4c90e77ec1",
69
+ "size": 626
70
+ },
71
+ "select_ctx_test.go": {
72
+ "mode": "0o644",
73
+ "sha256": "560d37ac028fbf92ba5c5a20b95af7d866a4fbdecd0e868b6fe266eb4849e665",
74
+ "size": 771
75
+ },
76
+ "select_test.go": {
77
+ "mode": "0o644",
78
+ "sha256": "3b06e89b5c358992a7165414dbeb4643820d95574981359638d609931d528630",
79
+ "size": 12209
80
+ },
81
+ "squirrel_ctx_test.go": {
82
+ "mode": "0o644",
83
+ "sha256": "4a052ae48d428a0719777189c407e5d5c7087550c0d99b2c28cceada083f76b0",
84
+ "size": 1277
85
+ },
86
+ "squirrel_test.go": {
87
+ "mode": "0o644",
88
+ "sha256": "7336a2ffda333c52c145d76e926a89e1244ff24b96c86abfc6fe06723572180f",
89
+ "size": 5780
90
+ },
91
+ "statement_test.go": {
92
+ "mode": "0o644",
93
+ "sha256": "a0f46fa71157b09eaca3da0fa6a75b25156cb552c785228836b0ffbb9fe5ac27",
94
+ "size": 2072
95
+ },
96
+ "stmtcacher_ctx_test.go": {
97
+ "mode": "0o644",
98
+ "sha256": "a0a1f49a87ebb6b35b8d66fbe9051d8a9f94346eaf5e3cd70719424433f5c878",
99
+ "size": 402
100
+ },
101
+ "stmtcacher_test.go": {
102
+ "mode": "0o644",
103
+ "sha256": "e5b5020ac3c194cf92121100a24df580955f32f89bd600b1e56014702d24eb52",
104
+ "size": 546
105
+ },
106
+ "update_ctx_test.go": {
107
+ "mode": "0o644",
108
+ "sha256": "3dd7bd0c17bfb61fad6e71c7736ca6a207f811ae7c3f92f8185c5f7d32dbf30a",
109
+ "size": 805
110
+ },
111
+ "update_test.go": {
112
+ "mode": "0o644",
113
+ "sha256": "6316c8d144c647d9c7bdd6b8be4490c40398da03d331be23c4729faa7a57aa4e",
114
+ "size": 2836
115
+ },
116
+ "where_test.go": {
117
+ "mode": "0o644",
118
+ "sha256": "1a53006a294c379a8b7f212b340acf9063ea0b613062a52fc9585a7d84f853f3",
119
+ "size": 1325
120
+ }
121
+ },
122
+ "public_files": {
123
+ ".gitignore": {
124
+ "mode": "0o644",
125
+ "sha256": "1eaa1ee4d30ac564ac002a67650eff426807e1fd8b9475250d0ef31ee3d458dd",
126
+ "size": 13
127
+ },
128
+ ".travis.yml": {
129
+ "mode": "0o644",
130
+ "sha256": "5409f254b7fc2f4ed3afcdc45ac2346acedadf2689e14f5d4735e5587cd31a15",
131
+ "size": 768
132
+ },
133
+ "LICENSE": {
134
+ "mode": "0o644",
135
+ "sha256": "11ac92da622d8d25df663d4bc5d12f464da1a98a9fbb75930e0e65cc58b80a2f",
136
+ "size": 1185
137
+ },
138
+ "README.md": {
139
+ "mode": "0o644",
140
+ "sha256": "f1dafb8f66d5eb204201e34fbcf50a08180b7cc6fffb9cd87ed55673d840afc2",
141
+ "size": 4363
142
+ },
143
+ "case.go": {
144
+ "mode": "0o644",
145
+ "sha256": "9c530c0585dcf3c1f12200afecbc2147edbdc18a2369f726486ebc169bfdb1f1",
146
+ "size": 3065
147
+ },
148
+ "delete.go": {
149
+ "mode": "0o644",
150
+ "sha256": "700cefe533a6d939aaa689dfcbf148ad8d4b07f0278337944ecc37767479b3eb",
151
+ "size": 4806
152
+ },
153
+ "delete_ctx.go": {
154
+ "mode": "0o644",
155
+ "sha256": "0fb7da25c0bee63500317da43e1d8bcb5b8d62487ec80e6298135953d62b03f4",
156
+ "size": 1908
157
+ },
158
+ "expr.go": {
159
+ "mode": "0o644",
160
+ "sha256": "246aa910b8adc931da8773bf9a782d8e8292c5315fd267d3aca2d75792842d8e",
161
+ "size": 9216
162
+ },
163
+ "go.mod": {
164
+ "mode": "0o644",
165
+ "sha256": "b4c6f216eafab7a1ca5209b5ddca006529666f72184aea72293395c69f7140f5",
166
+ "size": 321
167
+ },
168
+ "go.sum": {
169
+ "mode": "0o644",
170
+ "sha256": "2b4fe7850b36f8effe69d037ed1219df62399e4076034930b8f3d2edb7fa46fd",
171
+ "size": 953
172
+ },
173
+ "insert.go": {
174
+ "mode": "0o644",
175
+ "sha256": "626ac9dd6c5cbca5e9e3b93252d82c94d6d6b63ddc967fb0dbcee0f3dc889c2e",
176
+ "size": 7710
177
+ },
178
+ "insert_ctx.go": {
179
+ "mode": "0o644",
180
+ "sha256": "6f72f9fd2e5e3b9e60f65f1fcf920ba6724242784ba26b9e0924aa8a0667d8b2",
181
+ "size": 1908
182
+ },
183
+ "integration/doc.go": {
184
+ "mode": "0o644",
185
+ "sha256": "2eb5edda1be28404e1f6681d1177cd3f447f8167cacf51f817b853e578e5996c",
186
+ "size": 53
187
+ },
188
+ "integration/go.mod": {
189
+ "mode": "0o644",
190
+ "sha256": "b8f745640b55a496faf7e8ffe39dcbb223bd4a856c108f38cb5021c5c9fafc3b",
191
+ "size": 347
192
+ },
193
+ "integration/go.sum": {
194
+ "mode": "0o644",
195
+ "sha256": "30892c107aa863abb8105816d7f6fa497ec69fd1d6783f4f186a19ff0fe6df80",
196
+ "size": 3122
197
+ },
198
+ "part.go": {
199
+ "mode": "0o644",
200
+ "sha256": "5fb7ec420cb4f4eff065b0a71e073b8ac74a1a6a81647d19b490be9286bc2258",
201
+ "size": 1149
202
+ },
203
+ "placeholder.go": {
204
+ "mode": "0o644",
205
+ "sha256": "246a7219eb14597fa9322bac44691e6ff6f7437df8cf7e4f7fe15c263ce61114",
206
+ "size": 2558
207
+ },
208
+ "row.go": {
209
+ "mode": "0o644",
210
+ "sha256": "089fb1c058ccf2f6664c0cdaac097ad6616e5ec0b44939429bce737d70d9c50e",
211
+ "size": 472
212
+ },
213
+ "select.go": {
214
+ "mode": "0o644",
215
+ "sha256": "28ab9e3d2a9772d6e0ef08f4fa83ea1ccd4a246f086e0e9431a10e5d42504d33",
216
+ "size": 11320
217
+ },
218
+ "select_ctx.go": {
219
+ "mode": "0o644",
220
+ "sha256": "ac68ccbb975d46547f21be70d802af6f4de4ac4c41d9e26a925621e725d74787",
221
+ "size": 1908
222
+ },
223
+ "squirrel.go": {
224
+ "mode": "0o644",
225
+ "sha256": "a5d827d66fdd080a5f2efaccb74fca217265e995d667cf10a026dbc2871e70f9",
226
+ "size": 5074
227
+ },
228
+ "squirrel_ctx.go": {
229
+ "mode": "0o644",
230
+ "sha256": "2e903ebfb7941cb8f68100dc9c500b5bfb214ea8534aaa21e4ea7ed01a70085d",
231
+ "size": 3085
232
+ },
233
+ "statement.go": {
234
+ "mode": "0o644",
235
+ "sha256": "f6cbf3d520fe88614795a68113ea020dd9ad3977e9dcd42af6e0a48a906d2caa",
236
+ "size": 3254
237
+ },
238
+ "stmtcacher.go": {
239
+ "mode": "0o644",
240
+ "sha256": "8f1593570472ec435e653b16a331262629495915b8cf2fda9929e6c7fe0a3c5a",
241
+ "size": 2799
242
+ },
243
+ "stmtcacher_ctx.go": {
244
+ "mode": "0o644",
245
+ "sha256": "e0c02cbf487302ea082afa304b851c454ece0d85f7073c721afb9e5a9e32f7fc",
246
+ "size": 2550
247
+ },
248
+ "stmtcacher_noctx.go": {
249
+ "mode": "0o644",
250
+ "sha256": "14539e8754cc3ee236d7f8af2e0176fb5a8c6183d73ad0e797913ae51a400b22",
251
+ "size": 459
252
+ },
253
+ "update.go": {
254
+ "mode": "0o644",
255
+ "sha256": "f599719e6b0aef0c28cce127c979e5f89bf5cba9adaa317fc68d0840ed04386d",
256
+ "size": 7349
257
+ },
258
+ "update_ctx.go": {
259
+ "mode": "0o644",
260
+ "sha256": "517c4436ea62524889f3a50339d1d3c3ee89ff23050eecaf5fa3a973b8ec4bf0",
261
+ "size": 1908
262
+ },
263
+ "where.go": {
264
+ "mode": "0o644",
265
+ "sha256": "555836c5dd84cbd7571b5e2b3b5b677f3fcd4cc42a0f1cfb3a176f8909bd0755",
266
+ "size": 572
267
+ }
268
+ },
269
+ "reference_kind": "provided_healthy_parent_changed_implementation",
270
+ "runtime": {
271
+ "clean_runtime_qualified": false,
272
+ "config": {
273
+ "architecture": "amd64",
274
+ "digest": "sha256:8397c903899921169852f4bff3ee17f23d7d4f8eaf03854a2bffd0051a2b363f",
275
+ "os": "linux",
276
+ "sha256": "8397c903899921169852f4bff3ee17f23d7d4f8eaf03854a2bffd0051a2b363f"
277
+ },
278
+ "context_inventory_sha256": "8c63f6649adee8ca9a2290a98a9a180d45b9f65f42395812e6e97b409186f81d",
279
+ "image": "registry.hf.space/harness-hub-scale800-go-055c69f17f410bee-starter-v1@sha256:9dfb6b7417f54d78d50e6e6bdd951b854ed8da8f5f1782f4fe563a85e1cd0b7a",
280
+ "image_pull_qualified": false,
281
+ "provider_image_source_attestation": false,
282
+ "publication_receipt_sha256": "dc294274d204bc3953b3ddc9f385c54f9ded95ae55c720729f3b4765c2561bba",
283
+ "receipt_path": "production/runtime-images-extra-v1/resolutions/055c69f17f410bee/resolution.json",
284
+ "receipt_sha256": "741436358af5538a7e21351cbe2660ca3aeb440246407b654888e4766be1dc7a",
285
+ "registry_digest": "sha256:9dfb6b7417f54d78d50e6e6bdd951b854ed8da8f5f1782f4fe563a85e1cd0b7a",
286
+ "source_image": "docker.io/swebench/swesmith.x86_64.masterminds_1776_squirrel.1ded5784@sha256:8b7a7b2f6acd11416e98a5254735925f3e354c9a85634e37a1f9a347ad82ed22",
287
+ "source_receipt_sha256": "6be66b515dc9ca98b38e89389e4b485f038418a7591cd99ca1294782042078a3",
288
+ "space_commit": "4520e0fbd0db51041911578a6d2b53e5493f8b5a",
289
+ "space_id": "harness-hub/scale800-go-055c69f17f410bee-starter-v1",
290
+ "status": "registry_resolved_paused_unqualified"
291
+ },
292
+ "schema": "scale800-go-jobs-transform-v1",
293
+ "source_completion_sha256": "1108adf4e865c30f1bb8a7d70f3f0568438d9b69661a386f2ee0e6abd12a4a68",
294
+ "source_index_sha256": "c6a579667a10d7d11f14285e2bc349086351d67c49a8f378c797c819dea8a47f",
295
+ "source_inventory_verified": true,
296
+ "source_manifest_sha256": "bbe28efe04f8ddfc9f0e102d045abdb4509895b301302f06ffb08f5878627a21",
297
+ "source_proof_sha256": "eaab133fdafd3f4aeb0256e90f3063a615011c975a4b951746d3692622b847ef",
298
+ "source_record": {
299
+ "anti_training_canary": false,
300
+ "anti_training_reviewed": true,
301
+ "candidate_id": "swesmith-go:Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw",
302
+ "cloud_launch_ready": false,
303
+ "healthy_mirror_commit": "ecf2598064d7f630d661d9a03e6cab204d37eeb8",
304
+ "instruction_sha256": "fb88c785b6cd87a31c6c70a9a8bb08119fd20b6f766ea7d3060a66d9e7421241",
305
+ "is_fork": true,
306
+ "learner_path": "tasks/0379675216b16a1676ff1bef/learner",
307
+ "license_evidence": {
308
+ "source_code": {
309
+ "reviewed": true,
310
+ "sha256": "11ac92da622d8d25df663d4bc5d12f464da1a98a9fbb75930e0e65cc58b80a2f",
311
+ "spdx": "MIT",
312
+ "training_allowed": true,
313
+ "url": "https://raw.githubusercontent.com/swesmith/Masterminds__squirrel.1ded5784/2df379c9c99de79a1483ac96f1f196e3ba239b50/LICENSE"
314
+ },
315
+ "task_bundle": {
316
+ "basis": "Captured publisher MIT/train declaration; exact software permission separately checked per source",
317
+ "reviewed": true,
318
+ "sha256": "2e917153213a0f11a6d0f314e87d8092eb8289ae4dc767cdc020d024c7d5339f",
319
+ "spdx": "MIT",
320
+ "training_allowed": true,
321
+ "url": "https://huggingface.co/api/datasets/SWE-bench/SWE-smith-go/revision/d2f6ecc2cf8ae1af00fc790801bbacfa2913e015"
322
+ }
323
+ },
324
+ "original_source_commit": "1ded5784535dcffa4e175d4efbd1ca2706927758",
325
+ "patch_sha256": "fc2b75d1f00d8fdfdc91d32d55008aa1f537c1f4ec47d57f77786d360a5b488d",
326
+ "provenance_path": "tasks/0379675216b16a1676ff1bef/source-proof.json",
327
+ "repository_lineage": [
328
+ "swesmith/Masterminds__squirrel.1ded5784",
329
+ "Masterminds/squirrel"
330
+ ],
331
+ "rfc008_complete": false,
332
+ "runtime_qualified": false,
333
+ "runtime_test_identity_status": "pending_runtime_test_identity_resolution",
334
+ "semantic_nonoverlap_established": false,
335
+ "source_commit": "2df379c9c99de79a1483ac96f1f196e3ba239b50",
336
+ "source_dataset": "SWE-bench/SWE-smith-go",
337
+ "source_head_commit": "841935e5bc483a68832f664d4f147539c9145c49",
338
+ "source_kind": "mutation",
339
+ "source_repo": "swesmith/Masterminds__squirrel.1ded5784",
340
+ "source_revision": "d2f6ecc2cf8ae1af00fc790801bbacfa2913e015",
341
+ "source_split": "train",
342
+ "target_model_calibrated": false,
343
+ "task_id": "Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw",
344
+ "task_sha256": "d922013811d860ca048737d81aecd4348f76062704e89abd23e8c1e3ef0c9311",
345
+ "training_admissible": false,
346
+ "upstream_identity_reviewed": true,
347
+ "upstream_repo": "Masterminds/squirrel",
348
+ "usage": "quarantine_only"
349
+ },
350
+ "source_row_sha256": "bb111b54d76597e55203a99dd6cc85fec764810df1c910b4ca5bfc5240defe05",
351
+ "source_test_command": "go test -v ./...",
352
+ "target_model_calibrated": false,
353
+ "training_admissible": false,
354
+ "transfer_allowlist": [
355
+ "/testbed/.gitignore",
356
+ "/testbed/.travis.yml",
357
+ "/testbed/LICENSE",
358
+ "/testbed/README.md",
359
+ "/testbed/case.go",
360
+ "/testbed/delete.go",
361
+ "/testbed/delete_ctx.go",
362
+ "/testbed/expr.go",
363
+ "/testbed/go.mod",
364
+ "/testbed/go.sum",
365
+ "/testbed/insert.go",
366
+ "/testbed/insert_ctx.go",
367
+ "/testbed/integration/doc.go",
368
+ "/testbed/integration/go.mod",
369
+ "/testbed/integration/go.sum",
370
+ "/testbed/part.go",
371
+ "/testbed/placeholder.go",
372
+ "/testbed/row.go",
373
+ "/testbed/select.go",
374
+ "/testbed/select_ctx.go",
375
+ "/testbed/squirrel.go",
376
+ "/testbed/squirrel_ctx.go",
377
+ "/testbed/statement.go",
378
+ "/testbed/stmtcacher.go",
379
+ "/testbed/stmtcacher_ctx.go",
380
+ "/testbed/stmtcacher_noctx.go",
381
+ "/testbed/update.go",
382
+ "/testbed/update_ctx.go",
383
+ "/testbed/where.go"
384
+ ]
385
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/solution/solve.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -eu
3
+ /usr/local/bin/python -I - <<'OPENENV_REFERENCE'
4
+ import base64,json
5
+ from pathlib import Path
6
+ files=json.loads('{"update.go": {"data": "cGFja2FnZSBzcXVpcnJlbAoKaW1wb3J0ICgKCSJieXRlcyIKCSJkYXRhYmFzZS9zcWwiCgkiZm10IgoJInNvcnQiCgkic3RyaW5ncyIKCgkiZ2l0aHViLmNvbS9sYW5uL2J1aWxkZXIiCikKCnR5cGUgdXBkYXRlRGF0YSBzdHJ1Y3QgewoJUGxhY2Vob2xkZXJGb3JtYXQgUGxhY2Vob2xkZXJGb3JtYXQKCVJ1bldpdGggICAgICAgICAgIEJhc2VSdW5uZXIKCVByZWZpeGVzICAgICAgICAgIFtdU3FsaXplcgoJVGFibGUgICAgICAgICAgICAgc3RyaW5nCglTZXRDbGF1c2VzICAgICAgICBbXXNldENsYXVzZQoJRnJvbSAgICAgICAgICAgICAgU3FsaXplcgoJV2hlcmVQYXJ0cyAgICAgICAgW11TcWxpemVyCglPcmRlckJ5cyAgICAgICAgICBbXXN0cmluZwoJTGltaXQgICAgICAgICAgICAgc3RyaW5nCglPZmZzZXQgICAgICAgICAgICBzdHJpbmcKCVN1ZmZpeGVzICAgICAgICAgIFtdU3FsaXplcgp9Cgp0eXBlIHNldENsYXVzZSBzdHJ1Y3QgewoJY29sdW1uIHN0cmluZwoJdmFsdWUgIGludGVyZmFjZXt9Cn0KCmZ1bmMgKGQgKnVwZGF0ZURhdGEpIEV4ZWMoKSAoc3FsLlJlc3VsdCwgZXJyb3IpIHsKCWlmIGQuUnVuV2l0aCA9PSBuaWwgewoJCXJldHVybiBuaWwsIFJ1bm5lck5vdFNldAoJfQoJcmV0dXJuIEV4ZWNXaXRoKGQuUnVuV2l0aCwgZCkKfQoKZnVuYyAoZCAqdXBkYXRlRGF0YSkgUXVlcnkoKSAoKnNxbC5Sb3dzLCBlcnJvcikgewoJaWYgZC5SdW5XaXRoID09IG5pbCB7CgkJcmV0dXJuIG5pbCwgUnVubmVyTm90U2V0Cgl9CglyZXR1cm4gUXVlcnlXaXRoKGQuUnVuV2l0aCwgZCkKfQoKZnVuYyAoZCAqdXBkYXRlRGF0YSkgUXVlcnlSb3coKSBSb3dTY2FubmVyIHsKCWlmIGQuUnVuV2l0aCA9PSBuaWwgewoJCXJldHVybiAmUm93e2VycjogUnVubmVyTm90U2V0fQoJfQoJcXVlcnlSb3dlciwgb2sgOj0gZC5SdW5XaXRoLihRdWVyeVJvd2VyKQoJaWYgIW9rIHsKCQlyZXR1cm4gJlJvd3tlcnI6IFJ1bm5lck5vdFF1ZXJ5UnVubmVyfQoJfQoJcmV0dXJuIFF1ZXJ5Um93V2l0aChxdWVyeVJvd2VyLCBkKQp9CgpmdW5jIChkICp1cGRhdGVEYXRhKSBUb1NxbCgpIChzcWxTdHIgc3RyaW5nLCBhcmdzIFtdaW50ZXJmYWNle30sIGVyciBlcnJvcikgewoJaWYgbGVuKGQuVGFibGUpID09IDAgewoJCWVyciA9IGZtdC5FcnJvcmYoInVwZGF0ZSBzdGF0ZW1lbnRzIG11c3Qgc3BlY2lmeSBhIHRhYmxlIikKCQlyZXR1cm4KCX0KCWlmIGxlbihkLlNldENsYXVzZXMpID09IDAgewoJCWVyciA9IGZtdC5FcnJvcmYoInVwZGF0ZSBzdGF0ZW1lbnRzIG11c3QgaGF2ZSBhdCBsZWFzdCBvbmUgU2V0IGNsYXVzZSIpCgkJcmV0dXJuCgl9CgoJc3FsIDo9ICZieXRlcy5CdWZmZXJ7fQoKCWlmIGxlbihkLlByZWZpeGVzKSA+IDAgewoJCWFyZ3MsIGVyciA9IGFwcGVuZFRvU3FsKGQuUHJlZml4ZXMsIHNxbCwgIiAiLCBhcmdzKQoJCWlmIGVyciAhPSBuaWwgewoJCQlyZXR1cm4KCQl9CgoJCXNxbC5Xcml0ZVN0cmluZygiICIpCgl9CgoJc3FsLldyaXRlU3RyaW5nKCJVUERBVEUgIikKCXNxbC5Xcml0ZVN0cmluZyhkLlRhYmxlKQoKCXNxbC5Xcml0ZVN0cmluZygiIFNFVCAiKQoJc2V0U3FscyA6PSBtYWtlKFtdc3RyaW5nLCBsZW4oZC5TZXRDbGF1c2VzKSkKCWZvciBpLCBzZXRDbGF1c2UgOj0gcmFuZ2UgZC5TZXRDbGF1c2VzIHsKCQl2YXIgdmFsU3FsIHN0cmluZwoJCWlmIHZzLCBvayA6PSBzZXRDbGF1c2UudmFsdWUuKFNxbGl6ZXIpOyBvayB7CgkJCXZzcWwsIHZhcmdzLCBlcnIgOj0gdnMuVG9TcWwoKQoJCQlpZiBlcnIgIT0gbmlsIHsKCQkJCXJldHVybiAiIiwgbmlsLCBlcnIKCQkJfQoJCQlpZiBfLCBvayA6PSB2cy4oU2VsZWN0QnVpbGRlcik7IG9rIHsKCQkJCXZhbFNxbCA9IGZtdC5TcHJpbnRmKCIoJXMpIiwgdnNxbCkKCQkJfSBlbHNlIHsKCQkJCXZhbFNxbCA9IHZzcWwKCQkJfQoJCQlhcmdzID0gYXBwZW5kKGFyZ3MsIHZhcmdzLi4uKQoJCX0gZWxzZSB7CgkJCXZhbFNxbCA9ICI/IgoJCQlhcmdzID0gYXBwZW5kKGFyZ3MsIHNldENsYXVzZS52YWx1ZSkKCQl9CgkJc2V0U3Fsc1tpXSA9IGZtdC5TcHJpbnRmKCIlcyA9ICVzIiwgc2V0Q2xhdXNlLmNvbHVtbiwgdmFsU3FsKQoJfQoJc3FsLldyaXRlU3RyaW5nKHN0cmluZ3MuSm9pbihzZXRTcWxzLCAiLCAiKSkKCglpZiBkLkZyb20gIT0gbmlsIHsKCQlzcWwuV3JpdGVTdHJpbmcoIiBGUk9NICIpCgkJYXJncywgZXJyID0gYXBwZW5kVG9TcWwoW11TcWxpemVye2QuRnJvbX0sIHNxbCwgIiIsIGFyZ3MpCgkJaWYgZXJyICE9IG5pbCB7CgkJCXJldHVybgoJCX0KCX0KCglpZiBsZW4oZC5XaGVyZVBhcnRzKSA+IDAgewoJCXNxbC5Xcml0ZVN0cmluZygiIFdIRVJFICIpCgkJYXJncywgZXJyID0gYXBwZW5kVG9TcWwoZC5XaGVyZVBhcnRzLCBzcWwsICIgQU5EICIsIGFyZ3MpCgkJaWYgZXJyICE9IG5pbCB7CgkJCXJldHVybgoJCX0KCX0KCglpZiBsZW4oZC5PcmRlckJ5cykgPiAwIHsKCQlzcWwuV3JpdGVTdHJpbmcoIiBPUkRFUiBCWSAiKQoJCXNxbC5Xcml0ZVN0cmluZyhzdHJpbmdzLkpvaW4oZC5PcmRlckJ5cywgIiwgIikpCgl9CgoJaWYgbGVuKGQuTGltaXQpID4gMCB7CgkJc3FsLldyaXRlU3RyaW5nKCIgTElNSVQgIikKCQlzcWwuV3JpdGVTdHJpbmcoZC5MaW1pdCkKCX0KCglpZiBsZW4oZC5PZmZzZXQpID4gMCB7CgkJc3FsLldyaXRlU3RyaW5nKCIgT0ZGU0VUICIpCgkJc3FsLldyaXRlU3RyaW5nKGQuT2Zmc2V0KQoJfQoKCWlmIGxlbihkLlN1ZmZpeGVzKSA+IDAgewoJCXNxbC5Xcml0ZVN0cmluZygiICIpCgkJYXJncywgZXJyID0gYXBwZW5kVG9TcWwoZC5TdWZmaXhlcywgc3FsLCAiICIsIGFyZ3MpCgkJaWYgZXJyICE9IG5pbCB7CgkJCXJldHVybgoJCX0KCX0KCglzcWxTdHIsIGVyciA9IGQuUGxhY2Vob2xkZXJGb3JtYXQuUmVwbGFjZVBsYWNlaG9sZGVycyhzcWwuU3RyaW5nKCkpCglyZXR1cm4KfQoKLy8gQnVpbGRlcgoKLy8gVXBkYXRlQnVpbGRlciBidWlsZHMgU1FMIFVQREFURSBzdGF0ZW1lbnRzLgp0eXBlIFVwZGF0ZUJ1aWxkZXIgYnVpbGRlci5CdWlsZGVyCgpmdW5jIGluaXQoKSB7CglidWlsZGVyLlJlZ2lzdGVyKFVwZGF0ZUJ1aWxkZXJ7fSwgdXBkYXRlRGF0YXt9KQp9CgovLyBGb3JtYXQgbWV0aG9kcwoKLy8gUGxhY2Vob2xkZXJGb3JtYXQgc2V0cyBQbGFjZWhvbGRlckZvcm1hdCAoZS5nLiBRdWVzdGlvbiBvciBEb2xsYXIpIGZvciB0aGUKLy8gcXVlcnkuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgUGxhY2Vob2xkZXJGb3JtYXQoZiBQbGFjZWhvbGRlckZvcm1hdCkgVXBkYXRlQnVpbGRlciB7CglyZXR1cm4gYnVpbGRlci5TZXQoYiwgIlBsYWNlaG9sZGVyRm9ybWF0IiwgZikuKFVwZGF0ZUJ1aWxkZXIpCn0KCi8vIFJ1bm5lciBtZXRob2RzCgovLyBSdW5XaXRoIHNldHMgYSBSdW5uZXIgKGxpa2UgZGF0YWJhc2Uvc3FsLkRCKSB0byBiZSB1c2VkIHdpdGggZS5nLiBFeGVjLgpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIFJ1bldpdGgocnVubmVyIEJhc2VSdW5uZXIpIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIHNldFJ1bldpdGgoYiwgcnVubmVyKS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gRXhlYyBidWlsZHMgYW5kIEV4ZWNzIHRoZSBxdWVyeSB3aXRoIHRoZSBSdW5uZXIgc2V0IGJ5IFJ1bldpdGguCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgRXhlYygpIChzcWwuUmVzdWx0LCBlcnJvcikgewoJZGF0YSA6PSBidWlsZGVyLkdldFN0cnVjdChiKS4odXBkYXRlRGF0YSkKCXJldHVybiBkYXRhLkV4ZWMoKQp9CgpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIFF1ZXJ5KCkgKCpzcWwuUm93cywgZXJyb3IpIHsKCWRhdGEgOj0gYnVpbGRlci5HZXRTdHJ1Y3QoYikuKHVwZGF0ZURhdGEpCglyZXR1cm4gZGF0YS5RdWVyeSgpCn0KCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgUXVlcnlSb3coKSBSb3dTY2FubmVyIHsKCWRhdGEgOj0gYnVpbGRlci5HZXRTdHJ1Y3QoYikuKHVwZGF0ZURhdGEpCglyZXR1cm4gZGF0YS5RdWVyeVJvdygpCn0KCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgU2NhbihkZXN0IC4uLmludGVyZmFjZXt9KSBlcnJvciB7CglyZXR1cm4gYi5RdWVyeVJvdygpLlNjYW4oZGVzdC4uLikKfQoKLy8gU1FMIG1ldGhvZHMKCi8vIFRvU3FsIGJ1aWxkcyB0aGUgcXVlcnkgaW50byBhIFNRTCBzdHJpbmcgYW5kIGJvdW5kIGFyZ3MuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgVG9TcWwoKSAoc3RyaW5nLCBbXWludGVyZmFjZXt9LCBlcnJvcikgewoJZGF0YSA6PSBidWlsZGVyLkdldFN0cnVjdChiKS4odXBkYXRlRGF0YSkKCXJldHVybiBkYXRhLlRvU3FsKCkKfQoKLy8gTXVzdFNxbCBidWlsZHMgdGhlIHF1ZXJ5IGludG8gYSBTUUwgc3RyaW5nIGFuZCBib3VuZCBhcmdzLgovLyBJdCBwYW5pY3MgaWYgdGhlcmUgYXJlIGFueSBlcnJvcnMuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgTXVzdFNxbCgpIChzdHJpbmcsIFtdaW50ZXJmYWNle30pIHsKCXNxbCwgYXJncywgZXJyIDo9IGIuVG9TcWwoKQoJaWYgZXJyICE9IG5pbCB7CgkJcGFuaWMoZXJyKQoJfQoJcmV0dXJuIHNxbCwgYXJncwp9CgovLyBQcmVmaXggYWRkcyBhbiBleHByZXNzaW9uIHRvIHRoZSBiZWdpbm5pbmcgb2YgdGhlIHF1ZXJ5CmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgUHJlZml4KHNxbCBzdHJpbmcsIGFyZ3MgLi4uaW50ZXJmYWNle30pIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIGIuUHJlZml4RXhwcihFeHByKHNxbCwgYXJncy4uLikpCn0KCi8vIFByZWZpeEV4cHIgYWRkcyBhbiBleHByZXNzaW9uIHRvIHRoZSB2ZXJ5IGJlZ2lubmluZyBvZiB0aGUgcXVlcnkKZnVuYyAoYiBVcGRhdGVCdWlsZGVyKSBQcmVmaXhFeHByKGV4cHIgU3FsaXplcikgVXBkYXRlQnVpbGRlciB7CglyZXR1cm4gYnVpbGRlci5BcHBlbmQoYiwgIlByZWZpeGVzIiwgZXhwcikuKFVwZGF0ZUJ1aWxkZXIpCn0KCi8vIFRhYmxlIHNldHMgdGhlIHRhYmxlIHRvIGJlIHVwZGF0ZWQuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgVGFibGUodGFibGUgc3RyaW5nKSBVcGRhdGVCdWlsZGVyIHsKCXJldHVybiBidWlsZGVyLlNldChiLCAiVGFibGUiLCB0YWJsZSkuKFVwZGF0ZUJ1aWxkZXIpCn0KCi8vIFNldCBhZGRzIFNFVCBjbGF1c2VzIHRvIHRoZSBxdWVyeS4KZnVuYyAoYiBVcGRhdGVCdWlsZGVyKSBTZXQoY29sdW1uIHN0cmluZywgdmFsdWUgaW50ZXJmYWNle30pIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIGJ1aWxkZXIuQXBwZW5kKGIsICJTZXRDbGF1c2VzIiwgc2V0Q2xhdXNle2NvbHVtbjogY29sdW1uLCB2YWx1ZTogdmFsdWV9KS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gU2V0TWFwIGlzIGEgY29udmVuaWVuY2UgbWV0aG9kIHdoaWNoIGNhbGxzIC5TZXQgZm9yIGVhY2gga2V5L3ZhbHVlIHBhaXIgaW4gY2xhdXNlcy4KZnVuYyAoYiBVcGRhdGVCdWlsZGVyKSBTZXRNYXAoY2xhdXNlcyBtYXBbc3RyaW5nXWludGVyZmFjZXt9KSBVcGRhdGVCdWlsZGVyIHsKCWtleXMgOj0gbWFrZShbXXN0cmluZywgbGVuKGNsYXVzZXMpKQoJaSA6PSAwCglmb3Iga2V5IDo9IHJhbmdlIGNsYXVzZXMgewoJCWtleXNbaV0gPSBrZXkKCQlpKysKCX0KCXNvcnQuU3RyaW5ncyhrZXlzKQoJZm9yIF8sIGtleSA6PSByYW5nZSBrZXlzIHsKCQl2YWwsIF8gOj0gY2xhdXNlc1trZXldCgkJYiA9IGIuU2V0KGtleSwgdmFsKQoJfQoJcmV0dXJuIGIKfQoKLy8gRnJvbSBhZGRzIEZST00gY2xhdXNlIHRvIHRoZSBxdWVyeQovLyBGUk9NIGlzIHZhbGlkIGNvbnN0cnVjdCBpbiBwb3N0Z3Jlc3FsIG9ubHkuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgRnJvbShmcm9tIHN0cmluZykgVXBkYXRlQnVpbGRlciB7CglyZXR1cm4gYnVpbGRlci5TZXQoYiwgIkZyb20iLCBuZXdQYXJ0KGZyb20pKS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gRnJvbVNlbGVjdCBzZXRzIGEgc3VicXVlcnkgaW50byB0aGUgRlJPTSBjbGF1c2Ugb2YgdGhlIHF1ZXJ5LgpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIEZyb21TZWxlY3QoZnJvbSBTZWxlY3RCdWlsZGVyLCBhbGlhcyBzdHJpbmcpIFVwZGF0ZUJ1aWxkZXIgewoJLy8gUHJldmVudCBtaXNudW1iZXJlZCBwYXJhbWV0ZXJzIGluIG5lc3RlZCBzZWxlY3RzICgjMTgzKS4KCWZyb20gPSBmcm9tLlBsYWNlaG9sZGVyRm9ybWF0KFF1ZXN0aW9uKQoJcmV0dXJuIGJ1aWxkZXIuU2V0KGIsICJGcm9tIiwgQWxpYXMoZnJvbSwgYWxpYXMpKS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gV2hlcmUgYWRkcyBXSEVSRSBleHByZXNzaW9ucyB0byB0aGUgcXVlcnkuCi8vCi8vIFNlZSBTZWxlY3RCdWlsZGVyLldoZXJlIGZvciBtb3JlIGluZm9ybWF0aW9uLgpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIFdoZXJlKHByZWQgaW50ZXJmYWNle30sIGFyZ3MgLi4uaW50ZXJmYWNle30pIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIGJ1aWxkZXIuQXBwZW5kKGIsICJXaGVyZVBhcnRzIiwgbmV3V2hlcmVQYXJ0KHByZWQsIGFyZ3MuLi4pKS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gT3JkZXJCeSBhZGRzIE9SREVSIEJZIGV4cHJlc3Npb25zIHRvIHRoZSBxdWVyeS4KZnVuYyAoYiBVcGRhdGVCdWlsZGVyKSBPcmRlckJ5KG9yZGVyQnlzIC4uLnN0cmluZykgVXBkYXRlQnVpbGRlciB7CglyZXR1cm4gYnVpbGRlci5FeHRlbmQoYiwgIk9yZGVyQnlzIiwgb3JkZXJCeXMpLihVcGRhdGVCdWlsZGVyKQp9CgovLyBMaW1pdCBzZXRzIGEgTElNSVQgY2xhdXNlIG9uIHRoZSBxdWVyeS4KZnVuYyAoYiBVcGRhdGVCdWlsZGVyKSBMaW1pdChsaW1pdCB1aW50NjQpIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIGJ1aWxkZXIuU2V0KGIsICJMaW1pdCIsIGZtdC5TcHJpbnRmKCIlZCIsIGxpbWl0KSkuKFVwZGF0ZUJ1aWxkZXIpCn0KCi8vIE9mZnNldCBzZXRzIGEgT0ZGU0VUIGNsYXVzZSBvbiB0aGUgcXVlcnkuCmZ1bmMgKGIgVXBkYXRlQnVpbGRlcikgT2Zmc2V0KG9mZnNldCB1aW50NjQpIFVwZGF0ZUJ1aWxkZXIgewoJcmV0dXJuIGJ1aWxkZXIuU2V0KGIsICJPZmZzZXQiLCBmbXQuU3ByaW50ZigiJWQiLCBvZmZzZXQpKS4oVXBkYXRlQnVpbGRlcikKfQoKLy8gU3VmZml4IGFkZHMgYW4gZXhwcmVzc2lvbiB0byB0aGUgZW5kIG9mIHRoZSBxdWVyeQpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIFN1ZmZpeChzcWwgc3RyaW5nLCBhcmdzIC4uLmludGVyZmFjZXt9KSBVcGRhdGVCdWlsZGVyIHsKCXJldHVybiBiLlN1ZmZpeEV4cHIoRXhwcihzcWwsIGFyZ3MuLi4pKQp9CgovLyBTdWZmaXhFeHByIGFkZHMgYW4gZXhwcmVzc2lvbiB0byB0aGUgZW5kIG9mIHRoZSBxdWVyeQpmdW5jIChiIFVwZGF0ZUJ1aWxkZXIpIFN1ZmZpeEV4cHIoZXhwciBTcWxpemVyKSBVcGRhdGVCdWlsZGVyIHsKCXJldHVybiBidWlsZGVyLkFwcGVuZChiLCAiU3VmZml4ZXMiLCBleHByKS4oVXBkYXRlQnVpbGRlcikKfQo=", "mode": 420}}')
7
+ for name,item in files.items():
8
+ p=Path('/testbed')/name
9
+ p.parent.mkdir(parents=True,exist_ok=True)
10
+ p.write_bytes(base64.b64decode(item['data']))
11
+ p.chmod(item['mode'])
12
+ OPENENV_REFERENCE
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/task.toml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+ [agent]
3
+ timeout_sec = 300.0
4
+ [verifier]
5
+ timeout_sec = 300.0
6
+ environment_mode = "shared"
7
+ [environment]
8
+ docker_image = "ghcr.io/younesbelkada/scale800@sha256:482018eabb77fca4e02aeb63d502e7b1983f7345c734cf90cf34ef5270c4f05d"
9
+ cpus = 1
10
+ memory_mb = 2048
11
+ storage_mb = 4096
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/case_test.go ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/assert"
7
+ )
8
+
9
+ func TestCaseWithVal(t *testing.T) {
10
+ caseStmt := Case("number").
11
+ When("1", "one").
12
+ When("2", "two").
13
+ Else(Expr("?", "big number"))
14
+
15
+ qb := Select().
16
+ Column(caseStmt).
17
+ From("table")
18
+ sql, args, err := qb.ToSql()
19
+
20
+ assert.NoError(t, err)
21
+
22
+ expectedSql := "SELECT CASE number " +
23
+ "WHEN 1 THEN one " +
24
+ "WHEN 2 THEN two " +
25
+ "ELSE ? " +
26
+ "END " +
27
+ "FROM table"
28
+ assert.Equal(t, expectedSql, sql)
29
+
30
+ expectedArgs := []interface{}{"big number"}
31
+ assert.Equal(t, expectedArgs, args)
32
+ }
33
+
34
+ func TestCaseWithComplexVal(t *testing.T) {
35
+ caseStmt := Case("? > ?", 10, 5).
36
+ When("true", "'T'")
37
+
38
+ qb := Select().
39
+ Column(Alias(caseStmt, "complexCase")).
40
+ From("table")
41
+ sql, args, err := qb.ToSql()
42
+
43
+ assert.NoError(t, err)
44
+
45
+ expectedSql := "SELECT (CASE ? > ? " +
46
+ "WHEN true THEN 'T' " +
47
+ "END) AS complexCase " +
48
+ "FROM table"
49
+ assert.Equal(t, expectedSql, sql)
50
+
51
+ expectedArgs := []interface{}{10, 5}
52
+ assert.Equal(t, expectedArgs, args)
53
+ }
54
+
55
+ func TestCaseWithNoVal(t *testing.T) {
56
+ caseStmt := Case().
57
+ When(Eq{"x": 0}, "x is zero").
58
+ When(Expr("x > ?", 1), Expr("CONCAT('x is greater than ', ?)", 2))
59
+
60
+ qb := Select().Column(caseStmt).From("table")
61
+ sql, args, err := qb.ToSql()
62
+
63
+ assert.NoError(t, err)
64
+
65
+ expectedSql := "SELECT CASE " +
66
+ "WHEN x = ? THEN x is zero " +
67
+ "WHEN x > ? THEN CONCAT('x is greater than ', ?) " +
68
+ "END " +
69
+ "FROM table"
70
+
71
+ assert.Equal(t, expectedSql, sql)
72
+
73
+ expectedArgs := []interface{}{0, 1, 2}
74
+ assert.Equal(t, expectedArgs, args)
75
+ }
76
+
77
+ func TestCaseWithExpr(t *testing.T) {
78
+ caseStmt := Case(Expr("x = ?", true)).
79
+ When("true", Expr("?", "it's true!")).
80
+ Else("42")
81
+
82
+ qb := Select().Column(caseStmt).From("table")
83
+ sql, args, err := qb.ToSql()
84
+
85
+ assert.NoError(t, err)
86
+
87
+ expectedSql := "SELECT CASE x = ? " +
88
+ "WHEN true THEN ? " +
89
+ "ELSE 42 " +
90
+ "END " +
91
+ "FROM table"
92
+
93
+ assert.Equal(t, expectedSql, sql)
94
+
95
+ expectedArgs := []interface{}{true, "it's true!"}
96
+ assert.Equal(t, expectedArgs, args)
97
+ }
98
+
99
+ func TestMultipleCase(t *testing.T) {
100
+ caseStmtNoval := Case(Expr("x = ?", true)).
101
+ When("true", Expr("?", "it's true!")).
102
+ Else("42")
103
+ caseStmtExpr := Case().
104
+ When(Eq{"x": 0}, "'x is zero'").
105
+ When(Expr("x > ?", 1), Expr("CONCAT('x is greater than ', ?)", 2))
106
+
107
+ qb := Select().
108
+ Column(Alias(caseStmtNoval, "case_noval")).
109
+ Column(Alias(caseStmtExpr, "case_expr")).
110
+ From("table")
111
+
112
+ sql, args, err := qb.ToSql()
113
+
114
+ assert.NoError(t, err)
115
+
116
+ expectedSql := "SELECT " +
117
+ "(CASE x = ? WHEN true THEN ? ELSE 42 END) AS case_noval, " +
118
+ "(CASE WHEN x = ? THEN 'x is zero' WHEN x > ? THEN CONCAT('x is greater than ', ?) END) AS case_expr " +
119
+ "FROM table"
120
+
121
+ assert.Equal(t, expectedSql, sql)
122
+
123
+ expectedArgs := []interface{}{
124
+ true, "it's true!",
125
+ 0, 1, 2,
126
+ }
127
+ assert.Equal(t, expectedArgs, args)
128
+ }
129
+
130
+ func TestCaseWithNoWhenClause(t *testing.T) {
131
+ caseStmt := Case("something").
132
+ Else("42")
133
+
134
+ qb := Select().Column(caseStmt).From("table")
135
+
136
+ _, _, err := qb.ToSql()
137
+
138
+ assert.Error(t, err)
139
+
140
+ assert.Equal(t, "case expression must contain at lease one WHEN clause", err.Error())
141
+ }
142
+
143
+ func TestCaseBuilderMustSql(t *testing.T) {
144
+ defer func() {
145
+ if r := recover(); r == nil {
146
+ t.Errorf("TestCaseBuilderMustSql should have panicked!")
147
+ }
148
+ }()
149
+ Case("").MustSql()
150
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/delete_ctx_test.go ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ func TestDeleteBuilderContextRunners(t *testing.T) {
12
+ db := &DBStub{}
13
+ b := Delete("test").Where("x = ?", 1).RunWith(db)
14
+
15
+ expectedSql := "DELETE FROM test WHERE x = ?"
16
+
17
+ b.ExecContext(ctx)
18
+ assert.Equal(t, expectedSql, db.LastExecSql)
19
+
20
+ b.QueryContext(ctx)
21
+ assert.Equal(t, expectedSql, db.LastQuerySql)
22
+
23
+ b.QueryRowContext(ctx)
24
+ assert.Equal(t, expectedSql, db.LastQueryRowSql)
25
+
26
+ err := b.ScanContext(ctx)
27
+ assert.NoError(t, err)
28
+ }
29
+
30
+ func TestDeleteBuilderContextNoRunner(t *testing.T) {
31
+ b := Delete("test").Where("x != ?", 0).Suffix("RETURNING x")
32
+
33
+ _, err := b.ExecContext(ctx)
34
+ assert.Equal(t, RunnerNotSet, err)
35
+
36
+ _, err = b.QueryContext(ctx)
37
+ assert.Equal(t, RunnerNotSet, err)
38
+
39
+ err = b.ScanContext(ctx)
40
+ assert.Equal(t, RunnerNotSet, err)
41
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/delete_test.go ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/assert"
7
+ )
8
+
9
+ func TestDeleteBuilderToSql(t *testing.T) {
10
+ b := Delete("").
11
+ Prefix("WITH prefix AS ?", 0).
12
+ From("a").
13
+ Where("b = ?", 1).
14
+ OrderBy("c").
15
+ Limit(2).
16
+ Offset(3).
17
+ Suffix("RETURNING ?", 4)
18
+
19
+ sql, args, err := b.ToSql()
20
+ assert.NoError(t, err)
21
+
22
+ expectedSql :=
23
+ "WITH prefix AS ? " +
24
+ "DELETE FROM a WHERE b = ? ORDER BY c LIMIT 2 OFFSET 3 " +
25
+ "RETURNING ?"
26
+ assert.Equal(t, expectedSql, sql)
27
+
28
+ expectedArgs := []interface{}{0, 1, 4}
29
+ assert.Equal(t, expectedArgs, args)
30
+ }
31
+
32
+ func TestDeleteBuilderToSqlErr(t *testing.T) {
33
+ _, _, err := Delete("").ToSql()
34
+ assert.Error(t, err)
35
+ }
36
+
37
+ func TestDeleteBuilderMustSql(t *testing.T) {
38
+ defer func() {
39
+ if r := recover(); r == nil {
40
+ t.Errorf("TestDeleteBuilderMustSql should have panicked!")
41
+ }
42
+ }()
43
+ Delete("").MustSql()
44
+ }
45
+
46
+ func TestDeleteBuilderPlaceholders(t *testing.T) {
47
+ b := Delete("test").Where("x = ? AND y = ?", 1, 2)
48
+
49
+ sql, _, _ := b.PlaceholderFormat(Question).ToSql()
50
+ assert.Equal(t, "DELETE FROM test WHERE x = ? AND y = ?", sql)
51
+
52
+ sql, _, _ = b.PlaceholderFormat(Dollar).ToSql()
53
+ assert.Equal(t, "DELETE FROM test WHERE x = $1 AND y = $2", sql)
54
+ }
55
+
56
+ func TestDeleteBuilderRunners(t *testing.T) {
57
+ db := &DBStub{}
58
+ b := Delete("test").Where("x = ?", 1).RunWith(db)
59
+
60
+ expectedSql := "DELETE FROM test WHERE x = ?"
61
+
62
+ b.Exec()
63
+ assert.Equal(t, expectedSql, db.LastExecSql)
64
+ }
65
+
66
+ func TestDeleteBuilderNoRunner(t *testing.T) {
67
+ b := Delete("test")
68
+
69
+ _, err := b.Exec()
70
+ assert.Equal(t, RunnerNotSet, err)
71
+ }
72
+
73
+ func TestDeleteWithQuery(t *testing.T) {
74
+ db := &DBStub{}
75
+ b := Delete("test").Where("id=55").Suffix("RETURNING path").RunWith(db)
76
+
77
+ expectedSql := "DELETE FROM test WHERE id=55 RETURNING path"
78
+ b.Query()
79
+
80
+ assert.Equal(t, expectedSql, db.LastQuerySql)
81
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/expr_test.go ADDED
@@ -0,0 +1,464 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "database/sql"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestConcatExpr(t *testing.T) {
11
+ b := ConcatExpr("COALESCE(name,", Expr("CONCAT(?,' ',?)", "f", "l"), ")")
12
+ sql, args, err := b.ToSql()
13
+ assert.NoError(t, err)
14
+
15
+ expectedSql := "COALESCE(name,CONCAT(?,' ',?))"
16
+ assert.Equal(t, expectedSql, sql)
17
+
18
+ expectedArgs := []interface{}{"f", "l"}
19
+ assert.Equal(t, expectedArgs, args)
20
+ }
21
+
22
+ func TestConcatExprBadType(t *testing.T) {
23
+ b := ConcatExpr("prefix", 123, "suffix")
24
+ _, _, err := b.ToSql()
25
+ assert.Error(t, err)
26
+ assert.Contains(t, err.Error(), "123 is not")
27
+ }
28
+
29
+ func TestEqToSql(t *testing.T) {
30
+ b := Eq{"id": 1}
31
+ sql, args, err := b.ToSql()
32
+ assert.NoError(t, err)
33
+
34
+ expectedSql := "id = ?"
35
+ assert.Equal(t, expectedSql, sql)
36
+
37
+ expectedArgs := []interface{}{1}
38
+ assert.Equal(t, expectedArgs, args)
39
+ }
40
+
41
+ func TestEqEmptyToSql(t *testing.T) {
42
+ sql, args, err := Eq{}.ToSql()
43
+ assert.NoError(t, err)
44
+
45
+ expectedSql := "(1=1)"
46
+ assert.Equal(t, expectedSql, sql)
47
+ assert.Empty(t, args)
48
+ }
49
+
50
+ func TestEqInToSql(t *testing.T) {
51
+ b := Eq{"id": []int{1, 2, 3}}
52
+ sql, args, err := b.ToSql()
53
+ assert.NoError(t, err)
54
+
55
+ expectedSql := "id IN (?,?,?)"
56
+ assert.Equal(t, expectedSql, sql)
57
+
58
+ expectedArgs := []interface{}{1, 2, 3}
59
+ assert.Equal(t, expectedArgs, args)
60
+ }
61
+
62
+ func TestNotEqToSql(t *testing.T) {
63
+ b := NotEq{"id": 1}
64
+ sql, args, err := b.ToSql()
65
+ assert.NoError(t, err)
66
+
67
+ expectedSql := "id <> ?"
68
+ assert.Equal(t, expectedSql, sql)
69
+
70
+ expectedArgs := []interface{}{1}
71
+ assert.Equal(t, expectedArgs, args)
72
+ }
73
+
74
+ func TestEqNotInToSql(t *testing.T) {
75
+ b := NotEq{"id": []int{1, 2, 3}}
76
+ sql, args, err := b.ToSql()
77
+ assert.NoError(t, err)
78
+
79
+ expectedSql := "id NOT IN (?,?,?)"
80
+ assert.Equal(t, expectedSql, sql)
81
+
82
+ expectedArgs := []interface{}{1, 2, 3}
83
+ assert.Equal(t, expectedArgs, args)
84
+ }
85
+
86
+ func TestEqInEmptyToSql(t *testing.T) {
87
+ b := Eq{"id": []int{}}
88
+ sql, args, err := b.ToSql()
89
+ assert.NoError(t, err)
90
+
91
+ expectedSql := "(1=0)"
92
+ assert.Equal(t, expectedSql, sql)
93
+
94
+ expectedArgs := []interface{}{}
95
+ assert.Equal(t, expectedArgs, args)
96
+ }
97
+
98
+ func TestNotEqInEmptyToSql(t *testing.T) {
99
+ b := NotEq{"id": []int{}}
100
+ sql, args, err := b.ToSql()
101
+ assert.NoError(t, err)
102
+
103
+ expectedSql := "(1=1)"
104
+ assert.Equal(t, expectedSql, sql)
105
+
106
+ expectedArgs := []interface{}{}
107
+ assert.Equal(t, expectedArgs, args)
108
+ }
109
+
110
+ func TestEqBytesToSql(t *testing.T) {
111
+ b := Eq{"id": []byte("test")}
112
+ sql, args, err := b.ToSql()
113
+ assert.NoError(t, err)
114
+
115
+ expectedSql := "id = ?"
116
+ assert.Equal(t, expectedSql, sql)
117
+
118
+ expectedArgs := []interface{}{[]byte("test")}
119
+ assert.Equal(t, expectedArgs, args)
120
+ }
121
+
122
+ func TestLtToSql(t *testing.T) {
123
+ b := Lt{"id": 1}
124
+ sql, args, err := b.ToSql()
125
+ assert.NoError(t, err)
126
+
127
+ expectedSql := "id < ?"
128
+ assert.Equal(t, expectedSql, sql)
129
+
130
+ expectedArgs := []interface{}{1}
131
+ assert.Equal(t, expectedArgs, args)
132
+ }
133
+
134
+ func TestLtOrEqToSql(t *testing.T) {
135
+ b := LtOrEq{"id": 1}
136
+ sql, args, err := b.ToSql()
137
+ assert.NoError(t, err)
138
+
139
+ expectedSql := "id <= ?"
140
+ assert.Equal(t, expectedSql, sql)
141
+
142
+ expectedArgs := []interface{}{1}
143
+ assert.Equal(t, expectedArgs, args)
144
+ }
145
+
146
+ func TestGtToSql(t *testing.T) {
147
+ b := Gt{"id": 1}
148
+ sql, args, err := b.ToSql()
149
+ assert.NoError(t, err)
150
+
151
+ expectedSql := "id > ?"
152
+ assert.Equal(t, expectedSql, sql)
153
+
154
+ expectedArgs := []interface{}{1}
155
+ assert.Equal(t, expectedArgs, args)
156
+ }
157
+
158
+ func TestGtOrEqToSql(t *testing.T) {
159
+ b := GtOrEq{"id": 1}
160
+ sql, args, err := b.ToSql()
161
+ assert.NoError(t, err)
162
+
163
+ expectedSql := "id >= ?"
164
+ assert.Equal(t, expectedSql, sql)
165
+
166
+ expectedArgs := []interface{}{1}
167
+ assert.Equal(t, expectedArgs, args)
168
+ }
169
+
170
+ func TestExprNilToSql(t *testing.T) {
171
+ var b Sqlizer
172
+ b = NotEq{"name": nil}
173
+ sql, args, err := b.ToSql()
174
+ assert.NoError(t, err)
175
+ assert.Empty(t, args)
176
+
177
+ expectedSql := "name IS NOT NULL"
178
+ assert.Equal(t, expectedSql, sql)
179
+
180
+ b = Eq{"name": nil}
181
+ sql, args, err = b.ToSql()
182
+ assert.NoError(t, err)
183
+ assert.Empty(t, args)
184
+
185
+ expectedSql = "name IS NULL"
186
+ assert.Equal(t, expectedSql, sql)
187
+ }
188
+
189
+ func TestNullTypeString(t *testing.T) {
190
+ var b Sqlizer
191
+ var name sql.NullString
192
+
193
+ b = Eq{"name": name}
194
+ sql, args, err := b.ToSql()
195
+
196
+ assert.NoError(t, err)
197
+ assert.Empty(t, args)
198
+ assert.Equal(t, "name IS NULL", sql)
199
+
200
+ name.Scan("Name")
201
+ b = Eq{"name": name}
202
+ sql, args, err = b.ToSql()
203
+
204
+ assert.NoError(t, err)
205
+ assert.Equal(t, []interface{}{"Name"}, args)
206
+ assert.Equal(t, "name = ?", sql)
207
+ }
208
+
209
+ func TestNullTypeInt64(t *testing.T) {
210
+ var userID sql.NullInt64
211
+ userID.Scan(nil)
212
+ b := Eq{"user_id": userID}
213
+ sql, args, err := b.ToSql()
214
+
215
+ assert.NoError(t, err)
216
+ assert.Empty(t, args)
217
+ assert.Equal(t, "user_id IS NULL", sql)
218
+
219
+ userID.Scan(int64(10))
220
+ b = Eq{"user_id": userID}
221
+ sql, args, err = b.ToSql()
222
+
223
+ assert.NoError(t, err)
224
+ assert.Equal(t, []interface{}{int64(10)}, args)
225
+ assert.Equal(t, "user_id = ?", sql)
226
+ }
227
+
228
+ func TestNilPointer(t *testing.T) {
229
+ var name *string = nil
230
+ eq := Eq{"name": name}
231
+ sql, args, err := eq.ToSql()
232
+
233
+ assert.NoError(t, err)
234
+ assert.Empty(t, args)
235
+ assert.Equal(t, "name IS NULL", sql)
236
+
237
+ neq := NotEq{"name": name}
238
+ sql, args, err = neq.ToSql()
239
+
240
+ assert.NoError(t, err)
241
+ assert.Empty(t, args)
242
+ assert.Equal(t, "name IS NOT NULL", sql)
243
+
244
+ var ids *[]int = nil
245
+ eq = Eq{"id": ids}
246
+ sql, args, err = eq.ToSql()
247
+ assert.NoError(t, err)
248
+ assert.Empty(t, args)
249
+ assert.Equal(t, "id IS NULL", sql)
250
+
251
+ neq = NotEq{"id": ids}
252
+ sql, args, err = neq.ToSql()
253
+ assert.NoError(t, err)
254
+ assert.Empty(t, args)
255
+ assert.Equal(t, "id IS NOT NULL", sql)
256
+
257
+ var ida *[3]int = nil
258
+ eq = Eq{"id": ida}
259
+ sql, args, err = eq.ToSql()
260
+ assert.NoError(t, err)
261
+ assert.Empty(t, args)
262
+ assert.Equal(t, "id IS NULL", sql)
263
+
264
+ neq = NotEq{"id": ida}
265
+ sql, args, err = neq.ToSql()
266
+ assert.NoError(t, err)
267
+ assert.Empty(t, args)
268
+ assert.Equal(t, "id IS NOT NULL", sql)
269
+
270
+ }
271
+
272
+ func TestNotNilPointer(t *testing.T) {
273
+ c := "Name"
274
+ name := &c
275
+ eq := Eq{"name": name}
276
+ sql, args, err := eq.ToSql()
277
+
278
+ assert.NoError(t, err)
279
+ assert.Equal(t, []interface{}{"Name"}, args)
280
+ assert.Equal(t, "name = ?", sql)
281
+
282
+ neq := NotEq{"name": name}
283
+ sql, args, err = neq.ToSql()
284
+
285
+ assert.NoError(t, err)
286
+ assert.Equal(t, []interface{}{"Name"}, args)
287
+ assert.Equal(t, "name <> ?", sql)
288
+
289
+ s := []int{1, 2, 3}
290
+ ids := &s
291
+ eq = Eq{"id": ids}
292
+ sql, args, err = eq.ToSql()
293
+ assert.NoError(t, err)
294
+ assert.Equal(t, []interface{}{1, 2, 3}, args)
295
+ assert.Equal(t, "id IN (?,?,?)", sql)
296
+
297
+ neq = NotEq{"id": ids}
298
+ sql, args, err = neq.ToSql()
299
+ assert.NoError(t, err)
300
+ assert.Equal(t, []interface{}{1, 2, 3}, args)
301
+ assert.Equal(t, "id NOT IN (?,?,?)", sql)
302
+
303
+ a := [3]int{1, 2, 3}
304
+ ida := &a
305
+ eq = Eq{"id": ida}
306
+ sql, args, err = eq.ToSql()
307
+ assert.NoError(t, err)
308
+ assert.Equal(t, []interface{}{1, 2, 3}, args)
309
+ assert.Equal(t, "id IN (?,?,?)", sql)
310
+
311
+ neq = NotEq{"id": ida}
312
+ sql, args, err = neq.ToSql()
313
+ assert.NoError(t, err)
314
+ assert.Equal(t, []interface{}{1, 2, 3}, args)
315
+ assert.Equal(t, "id NOT IN (?,?,?)", sql)
316
+ }
317
+
318
+ func TestEmptyAndToSql(t *testing.T) {
319
+ sql, args, err := And{}.ToSql()
320
+ assert.NoError(t, err)
321
+
322
+ expectedSql := "(1=1)"
323
+ assert.Equal(t, expectedSql, sql)
324
+
325
+ expectedArgs := []interface{}{}
326
+ assert.Equal(t, expectedArgs, args)
327
+ }
328
+
329
+ func TestEmptyOrToSql(t *testing.T) {
330
+ sql, args, err := Or{}.ToSql()
331
+ assert.NoError(t, err)
332
+
333
+ expectedSql := "(1=0)"
334
+ assert.Equal(t, expectedSql, sql)
335
+
336
+ expectedArgs := []interface{}{}
337
+ assert.Equal(t, expectedArgs, args)
338
+ }
339
+
340
+ func TestLikeToSql(t *testing.T) {
341
+ b := Like{"name": "%irrel"}
342
+ sql, args, err := b.ToSql()
343
+ assert.NoError(t, err)
344
+
345
+ expectedSql := "name LIKE ?"
346
+ assert.Equal(t, expectedSql, sql)
347
+
348
+ expectedArgs := []interface{}{"%irrel"}
349
+ assert.Equal(t, expectedArgs, args)
350
+ }
351
+
352
+ func TestNotLikeToSql(t *testing.T) {
353
+ b := NotLike{"name": "%irrel"}
354
+ sql, args, err := b.ToSql()
355
+ assert.NoError(t, err)
356
+
357
+ expectedSql := "name NOT LIKE ?"
358
+ assert.Equal(t, expectedSql, sql)
359
+
360
+ expectedArgs := []interface{}{"%irrel"}
361
+ assert.Equal(t, expectedArgs, args)
362
+ }
363
+
364
+ func TestILikeToSql(t *testing.T) {
365
+ b := ILike{"name": "sq%"}
366
+ sql, args, err := b.ToSql()
367
+ assert.NoError(t, err)
368
+
369
+ expectedSql := "name ILIKE ?"
370
+ assert.Equal(t, expectedSql, sql)
371
+
372
+ expectedArgs := []interface{}{"sq%"}
373
+ assert.Equal(t, expectedArgs, args)
374
+ }
375
+
376
+ func TestNotILikeToSql(t *testing.T) {
377
+ b := NotILike{"name": "sq%"}
378
+ sql, args, err := b.ToSql()
379
+ assert.NoError(t, err)
380
+
381
+ expectedSql := "name NOT ILIKE ?"
382
+ assert.Equal(t, expectedSql, sql)
383
+
384
+ expectedArgs := []interface{}{"sq%"}
385
+ assert.Equal(t, expectedArgs, args)
386
+ }
387
+
388
+ func TestSqlEqOrder(t *testing.T) {
389
+ b := Eq{"a": 1, "b": 2, "c": 3}
390
+ sql, args, err := b.ToSql()
391
+ assert.NoError(t, err)
392
+
393
+ expectedSql := "a = ? AND b = ? AND c = ?"
394
+ assert.Equal(t, expectedSql, sql)
395
+
396
+ expectedArgs := []interface{}{1, 2, 3}
397
+ assert.Equal(t, expectedArgs, args)
398
+ }
399
+
400
+ func TestSqlLtOrder(t *testing.T) {
401
+ b := Lt{"a": 1, "b": 2, "c": 3}
402
+ sql, args, err := b.ToSql()
403
+ assert.NoError(t, err)
404
+
405
+ expectedSql := "a < ? AND b < ? AND c < ?"
406
+ assert.Equal(t, expectedSql, sql)
407
+
408
+ expectedArgs := []interface{}{1, 2, 3}
409
+ assert.Equal(t, expectedArgs, args)
410
+ }
411
+
412
+ func TestExprEscaped(t *testing.T) {
413
+ b := Expr("count(??)", Expr("x"))
414
+ sql, args, err := b.ToSql()
415
+ assert.NoError(t, err)
416
+
417
+ expectedSql := "count(??)"
418
+ assert.Equal(t, expectedSql, sql)
419
+
420
+ expectedArgs := []interface{}{Expr("x")}
421
+ assert.Equal(t, expectedArgs, args)
422
+ }
423
+
424
+ func TestExprRecursion(t *testing.T) {
425
+ {
426
+ b := Expr("count(?)", Expr("nullif(a,?)", "b"))
427
+ sql, args, err := b.ToSql()
428
+ assert.NoError(t, err)
429
+
430
+ expectedSql := "count(nullif(a,?))"
431
+ assert.Equal(t, expectedSql, sql)
432
+
433
+ expectedArgs := []interface{}{"b"}
434
+ assert.Equal(t, expectedArgs, args)
435
+ }
436
+ {
437
+ b := Expr("extract(? from ?)", Expr("epoch"), "2001-02-03")
438
+ sql, args, err := b.ToSql()
439
+ assert.NoError(t, err)
440
+
441
+ expectedSql := "extract(epoch from ?)"
442
+ assert.Equal(t, expectedSql, sql)
443
+
444
+ expectedArgs := []interface{}{"2001-02-03"}
445
+ assert.Equal(t, expectedArgs, args)
446
+ }
447
+ {
448
+ b := Expr("JOIN t1 ON ?", And{Eq{"id": 1}, Expr("NOT c1"), Expr("? @@ ?", "x", "y")})
449
+ sql, args, err := b.ToSql()
450
+ assert.NoError(t, err)
451
+
452
+ expectedSql := "JOIN t1 ON (id = ? AND NOT c1 AND ? @@ ?)"
453
+ assert.Equal(t, expectedSql, sql)
454
+
455
+ expectedArgs := []interface{}{1, "x", "y"}
456
+ assert.Equal(t, expectedArgs, args)
457
+ }
458
+ }
459
+
460
+ func ExampleEq() {
461
+ Select("id", "created", "first_name").From("users").Where(Eq{
462
+ "company": 20,
463
+ })
464
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/insert_ctx_test.go ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ func TestInsertBuilderContextRunners(t *testing.T) {
12
+ db := &DBStub{}
13
+ b := Insert("test").Values(1).RunWith(db)
14
+
15
+ expectedSql := "INSERT INTO test VALUES (?)"
16
+
17
+ b.ExecContext(ctx)
18
+ assert.Equal(t, expectedSql, db.LastExecSql)
19
+
20
+ b.QueryContext(ctx)
21
+ assert.Equal(t, expectedSql, db.LastQuerySql)
22
+
23
+ b.QueryRowContext(ctx)
24
+ assert.Equal(t, expectedSql, db.LastQueryRowSql)
25
+
26
+ err := b.ScanContext(ctx)
27
+ assert.NoError(t, err)
28
+ }
29
+
30
+ func TestInsertBuilderContextNoRunner(t *testing.T) {
31
+ b := Insert("test").Values(1)
32
+
33
+ _, err := b.ExecContext(ctx)
34
+ assert.Equal(t, RunnerNotSet, err)
35
+
36
+ _, err = b.QueryContext(ctx)
37
+ assert.Equal(t, RunnerNotSet, err)
38
+
39
+ err = b.ScanContext(ctx)
40
+ assert.Equal(t, RunnerNotSet, err)
41
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/insert_test.go ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/assert"
7
+ )
8
+
9
+ func TestInsertBuilderToSql(t *testing.T) {
10
+ b := Insert("").
11
+ Prefix("WITH prefix AS ?", 0).
12
+ Into("a").
13
+ Options("DELAYED", "IGNORE").
14
+ Columns("b", "c").
15
+ Values(1, 2).
16
+ Values(3, Expr("? + 1", 4)).
17
+ Suffix("RETURNING ?", 5)
18
+
19
+ sql, args, err := b.ToSql()
20
+ assert.NoError(t, err)
21
+
22
+ expectedSQL :=
23
+ "WITH prefix AS ? " +
24
+ "INSERT DELAYED IGNORE INTO a (b,c) VALUES (?,?),(?,? + 1) " +
25
+ "RETURNING ?"
26
+ assert.Equal(t, expectedSQL, sql)
27
+
28
+ expectedArgs := []interface{}{0, 1, 2, 3, 4, 5}
29
+ assert.Equal(t, expectedArgs, args)
30
+ }
31
+
32
+ func TestInsertBuilderToSqlErr(t *testing.T) {
33
+ _, _, err := Insert("").Values(1).ToSql()
34
+ assert.Error(t, err)
35
+
36
+ _, _, err = Insert("x").ToSql()
37
+ assert.Error(t, err)
38
+ }
39
+
40
+ func TestInsertBuilderMustSql(t *testing.T) {
41
+ defer func() {
42
+ if r := recover(); r == nil {
43
+ t.Errorf("TestInsertBuilderMustSql should have panicked!")
44
+ }
45
+ }()
46
+ Insert("").MustSql()
47
+ }
48
+
49
+ func TestInsertBuilderPlaceholders(t *testing.T) {
50
+ b := Insert("test").Values(1, 2)
51
+
52
+ sql, _, _ := b.PlaceholderFormat(Question).ToSql()
53
+ assert.Equal(t, "INSERT INTO test VALUES (?,?)", sql)
54
+
55
+ sql, _, _ = b.PlaceholderFormat(Dollar).ToSql()
56
+ assert.Equal(t, "INSERT INTO test VALUES ($1,$2)", sql)
57
+ }
58
+
59
+ func TestInsertBuilderRunners(t *testing.T) {
60
+ db := &DBStub{}
61
+ b := Insert("test").Values(1).RunWith(db)
62
+
63
+ expectedSQL := "INSERT INTO test VALUES (?)"
64
+
65
+ b.Exec()
66
+ assert.Equal(t, expectedSQL, db.LastExecSql)
67
+ }
68
+
69
+ func TestInsertBuilderNoRunner(t *testing.T) {
70
+ b := Insert("test").Values(1)
71
+
72
+ _, err := b.Exec()
73
+ assert.Equal(t, RunnerNotSet, err)
74
+ }
75
+
76
+ func TestInsertBuilderSetMap(t *testing.T) {
77
+ b := Insert("table").SetMap(Eq{"field1": 1, "field2": 2, "field3": 3})
78
+
79
+ sql, args, err := b.ToSql()
80
+ assert.NoError(t, err)
81
+
82
+ expectedSQL := "INSERT INTO table (field1,field2,field3) VALUES (?,?,?)"
83
+ assert.Equal(t, expectedSQL, sql)
84
+
85
+ expectedArgs := []interface{}{1, 2, 3}
86
+ assert.Equal(t, expectedArgs, args)
87
+ }
88
+
89
+ func TestInsertBuilderSelect(t *testing.T) {
90
+ sb := Select("field1").From("table1").Where(Eq{"field1": 1})
91
+ ib := Insert("table2").Columns("field1").Select(sb)
92
+
93
+ sql, args, err := ib.ToSql()
94
+ assert.NoError(t, err)
95
+
96
+ expectedSQL := "INSERT INTO table2 (field1) SELECT field1 FROM table1 WHERE field1 = ?"
97
+ assert.Equal(t, expectedSQL, sql)
98
+
99
+ expectedArgs := []interface{}{1}
100
+ assert.Equal(t, expectedArgs, args)
101
+ }
102
+
103
+ func TestInsertBuilderReplace(t *testing.T) {
104
+ b := Replace("table").Values(1)
105
+
106
+ expectedSQL := "REPLACE INTO table VALUES (?)"
107
+
108
+ sql, _, err := b.ToSql()
109
+ assert.NoError(t, err)
110
+
111
+ assert.Equal(t, expectedSQL, sql)
112
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/integration/integration_test.go ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package integration
2
+
3
+ import (
4
+ "context"
5
+ "database/sql"
6
+ "flag"
7
+ "fmt"
8
+ "os"
9
+ "testing"
10
+
11
+ "github.com/stretchr/testify/assert"
12
+
13
+ sqrl "github.com/Masterminds/squirrel"
14
+
15
+ _ "github.com/go-sql-driver/mysql"
16
+ _ "github.com/lib/pq"
17
+ _ "github.com/mattn/go-sqlite3"
18
+ )
19
+
20
+ const (
21
+ testSchema = `
22
+ CREATE TABLE squirrel_integration ( k INT, v TEXT )`
23
+ testData = `
24
+ INSERT INTO squirrel_integration VALUES
25
+ (1, 'foo'),
26
+ (3, 'bar'),
27
+ (2, 'foo'),
28
+ (4, 'baz')
29
+ `
30
+ )
31
+
32
+ var (
33
+ sb sqrl.StatementBuilderType
34
+ )
35
+
36
+ func TestMain(m *testing.M) {
37
+ var driver, dataSource string
38
+ flag.StringVar(&driver, "driver", "", "integration database driver")
39
+ flag.StringVar(&dataSource, "dataSource", "", "integration database data source")
40
+ flag.Parse()
41
+
42
+ if driver == "" {
43
+ driver = "sqlite3"
44
+ }
45
+
46
+ if driver == "sqlite3" && dataSource == "" {
47
+ dataSource = ":memory:"
48
+ }
49
+
50
+ db, err := sql.Open(driver, dataSource)
51
+ if err != nil {
52
+ fmt.Printf("error opening database: %v\n", err)
53
+ os.Exit(-1)
54
+ }
55
+
56
+ _, err = db.Exec(testSchema)
57
+ if err != nil {
58
+ fmt.Printf("error creating test schema: %v\n", err)
59
+ os.Exit(-2)
60
+ }
61
+
62
+ defer func() {
63
+ _, err = db.Exec("DROP TABLE squirrel_integration")
64
+ fmt.Printf("error removing test schema: %v\n", err)
65
+ }()
66
+
67
+ _, err = db.Exec(testData)
68
+ if err != nil {
69
+ fmt.Printf("error inserting test data: %v\n", err)
70
+ os.Exit(-3)
71
+ }
72
+
73
+ sb = sqrl.StatementBuilder.RunWith(db)
74
+
75
+ if driver == "postgres" {
76
+ sb = sb.PlaceholderFormat(sqrl.Dollar)
77
+ }
78
+
79
+ os.Exit(m.Run())
80
+ }
81
+
82
+ func assertVals(t *testing.T, s sqrl.SelectBuilder, expected ...string) {
83
+ rows, err := s.Query()
84
+ assert.NoError(t, err)
85
+ defer rows.Close()
86
+
87
+ vals := make([]string, len(expected))
88
+ for i := range vals {
89
+ assert.True(t, rows.Next())
90
+ assert.NoError(t, rows.Scan(&vals[i]))
91
+ }
92
+ assert.False(t, rows.Next())
93
+
94
+ if expected != nil {
95
+ assert.Equal(t, expected, vals)
96
+ }
97
+ }
98
+
99
+ func TestSimpleSelect(t *testing.T) {
100
+ assertVals(
101
+ t,
102
+ sb.Select("v").From("squirrel_integration"),
103
+ "foo", "bar", "foo", "baz")
104
+ }
105
+
106
+ func TestEq(t *testing.T) {
107
+ s := sb.Select("v").From("squirrel_integration")
108
+ assertVals(t, s.Where(sqrl.Eq{"k": 4}), "baz")
109
+ assertVals(t, s.Where(sqrl.NotEq{"k": 2}), "foo", "bar", "baz")
110
+ assertVals(t, s.Where(sqrl.Eq{"k": []int{1, 4}}), "foo", "baz")
111
+ assertVals(t, s.Where(sqrl.NotEq{"k": []int{1, 4}}), "bar", "foo")
112
+ assertVals(t, s.Where(sqrl.Eq{"k": nil}))
113
+ assertVals(t, s.Where(sqrl.NotEq{"k": nil}), "foo", "bar", "foo", "baz")
114
+ assertVals(t, s.Where(sqrl.Eq{"k": []int{}}))
115
+ assertVals(t, s.Where(sqrl.NotEq{"k": []int{}}), "foo", "bar", "foo", "baz")
116
+ }
117
+
118
+ func TestIneq(t *testing.T) {
119
+ s := sb.Select("v").From("squirrel_integration")
120
+ assertVals(t, s.Where(sqrl.Lt{"k": 3}), "foo", "foo")
121
+ assertVals(t, s.Where(sqrl.Gt{"k": 3}), "baz")
122
+ }
123
+
124
+ func TestConj(t *testing.T) {
125
+ s := sb.Select("v").From("squirrel_integration")
126
+ assertVals(t, s.Where(sqrl.And{sqrl.Gt{"k": 1}, sqrl.Lt{"k": 4}}), "bar", "foo")
127
+ assertVals(t, s.Where(sqrl.Or{sqrl.Gt{"k": 3}, sqrl.Lt{"k": 2}}), "foo", "baz")
128
+ }
129
+
130
+ func TestContext(t *testing.T) {
131
+ s := sb.Select("v").From("squirrel_integration")
132
+ ctx := context.Background()
133
+ _, err := s.QueryContext(ctx)
134
+ assert.NoError(t, err)
135
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/placeholder_test.go ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "strings"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestQuestion(t *testing.T) {
11
+ sql := "x = ? AND y = ?"
12
+ s, _ := Question.ReplacePlaceholders(sql)
13
+ assert.Equal(t, sql, s)
14
+ }
15
+
16
+ func TestDollar(t *testing.T) {
17
+ sql := "x = ? AND y = ?"
18
+ s, _ := Dollar.ReplacePlaceholders(sql)
19
+ assert.Equal(t, "x = $1 AND y = $2", s)
20
+ }
21
+
22
+ func TestColon(t *testing.T) {
23
+ sql := "x = ? AND y = ?"
24
+ s, _ := Colon.ReplacePlaceholders(sql)
25
+ assert.Equal(t, "x = :1 AND y = :2", s)
26
+ }
27
+
28
+ func TestAtp(t *testing.T) {
29
+ sql := "x = ? AND y = ?"
30
+ s, _ := AtP.ReplacePlaceholders(sql)
31
+ assert.Equal(t, "x = @p1 AND y = @p2", s)
32
+ }
33
+
34
+ func TestPlaceholders(t *testing.T) {
35
+ assert.Equal(t, Placeholders(2), "?,?")
36
+ }
37
+
38
+ func TestEscapeDollar(t *testing.T) {
39
+ sql := "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ??| array['?'] AND enabled = ?"
40
+ s, _ := Dollar.ReplacePlaceholders(sql)
41
+ assert.Equal(t, "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ?| array['$1'] AND enabled = $2", s)
42
+ }
43
+
44
+ func TestEscapeColon(t *testing.T) {
45
+ sql := "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ??| array['?'] AND enabled = ?"
46
+ s, _ := Colon.ReplacePlaceholders(sql)
47
+ assert.Equal(t, "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ?| array[':1'] AND enabled = :2", s)
48
+ }
49
+
50
+ func TestEscapeAtp(t *testing.T) {
51
+ sql := "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ??| array['?'] AND enabled = ?"
52
+ s, _ := AtP.ReplacePlaceholders(sql)
53
+ assert.Equal(t, "SELECT uuid, \"data\" #> '{tags}' AS tags FROM nodes WHERE \"data\" -> 'tags' ?| array['@p1'] AND enabled = @p2", s)
54
+ }
55
+
56
+ func BenchmarkPlaceholdersArray(b *testing.B) {
57
+ var count = b.N
58
+ placeholders := make([]string, count)
59
+ for i := 0; i < count; i++ {
60
+ placeholders[i] = "?"
61
+ }
62
+ var _ = strings.Join(placeholders, ",")
63
+ }
64
+
65
+ func BenchmarkPlaceholdersStrings(b *testing.B) {
66
+ Placeholders(b.N)
67
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/row_test.go ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "fmt"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ type RowStub struct {
11
+ Scanned bool
12
+ }
13
+
14
+ func (r *RowStub) Scan(_ ...interface{}) error {
15
+ r.Scanned = true
16
+ return nil
17
+ }
18
+
19
+ func TestRowScan(t *testing.T) {
20
+ stub := &RowStub{}
21
+ row := &Row{RowScanner: stub}
22
+ err := row.Scan()
23
+ assert.True(t, stub.Scanned, "row was not scanned")
24
+ assert.NoError(t, err)
25
+ }
26
+
27
+ func TestRowScanErr(t *testing.T) {
28
+ stub := &RowStub{}
29
+ rowErr := fmt.Errorf("scan err")
30
+ row := &Row{RowScanner: stub, err: rowErr}
31
+ err := row.Scan()
32
+ assert.False(t, stub.Scanned, "row was scanned")
33
+ assert.Equal(t, rowErr, err)
34
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/select_ctx_test.go ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // +build go1.8
2
+
3
+ package squirrel
4
+
5
+ import (
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ func TestSelectBuilderContextRunners(t *testing.T) {
12
+ db := &DBStub{}
13
+ b := Select("test").RunWith(db)
14
+
15
+ expectedSql := "SELECT test"
16
+
17
+ b.ExecContext(ctx)
18
+ assert.Equal(t, expectedSql, db.LastExecSql)
19
+
20
+ b.QueryContext(ctx)
21
+ assert.Equal(t, expectedSql, db.LastQuerySql)
22
+
23
+ b.QueryRowContext(ctx)
24
+ assert.Equal(t, expectedSql, db.LastQueryRowSql)
25
+
26
+ err := b.ScanContext(ctx)
27
+ assert.NoError(t, err)
28
+ }
29
+
30
+ func TestSelectBuilderContextNoRunner(t *testing.T) {
31
+ b := Select("test")
32
+
33
+ _, err := b.ExecContext(ctx)
34
+ assert.Equal(t, RunnerNotSet, err)
35
+
36
+ _, err = b.QueryContext(ctx)
37
+ assert.Equal(t, RunnerNotSet, err)
38
+
39
+ err = b.ScanContext(ctx)
40
+ assert.Equal(t, RunnerNotSet, err)
41
+ }
tasks/Masterminds__squirrel.1ded5784.func_pm_ctrl_invert_if__coeoegdw/tests/frozen/select_test.go ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package squirrel
2
+
3
+ import (
4
+ "database/sql"
5
+ "fmt"
6
+ "log"
7
+ "testing"
8
+ "time"
9
+
10
+ "github.com/stretchr/testify/assert"
11
+ )
12
+
13
+ func TestSelectBuilderToSql(t *testing.T) {
14
+ subQ := Select("aa", "bb").From("dd")
15
+ b := Select("a", "b").
16
+ Prefix("WITH prefix AS ?", 0).
17
+ Distinct().
18
+ Columns("c").
19
+ Column("IF(d IN ("+Placeholders(3)+"), 1, 0) as stat_column", 1, 2, 3).
20
+ Column(Expr("a > ?", 100)).
21
+ Column(Alias(Eq{"b": []int{101, 102, 103}}, "b_alias")).
22
+ Column(Alias(subQ, "subq")).
23
+ From("e").
24
+ JoinClause("CROSS JOIN j1").
25
+ Join("j2").
26
+ LeftJoin("j3").
27
+ RightJoin("j4").
28
+ InnerJoin("j5").
29
+ CrossJoin("j6").
30
+ Where("f = ?", 4).
31
+ Where(Eq{"g": 5}).
32
+ Where(map[string]interface{}{"h": 6}).
33
+ Where(Eq{"i": []int{7, 8, 9}}).
34
+ Where(Or{Expr("j = ?", 10), And{Eq{"k": 11}, Expr("true")}}).
35
+ GroupBy("l").
36
+ Having("m = n").
37
+ OrderByClause("? DESC", 1).
38
+ OrderBy("o ASC", "p DESC").
39
+ Limit(12).
40
+ Offset(13).
41
+ Suffix("FETCH FIRST ? ROWS ONLY", 14)
42
+
43
+ sql, args, err := b.ToSql()
44
+ assert.NoError(t, err)
45
+
46
+ expectedSql :=
47
+ "WITH prefix AS ? " +
48
+ "SELECT DISTINCT a, b, c, IF(d IN (?,?,?), 1, 0) as stat_column, a > ?, " +
49
+ "(b IN (?,?,?)) AS b_alias, " +
50
+ "(SELECT aa, bb FROM dd) AS subq " +
51
+ "FROM e " +
52
+ "CROSS JOIN j1 JOIN j2 LEFT JOIN j3 RIGHT JOIN j4 INNER JOIN j5 CROSS JOIN j6 " +
53
+ "WHERE f = ? AND g = ? AND h = ? AND i IN (?,?,?) AND (j = ? OR (k = ? AND true)) " +
54
+ "GROUP BY l HAVING m = n ORDER BY ? DESC, o ASC, p DESC LIMIT 12 OFFSET 13 " +
55
+ "FETCH FIRST ? ROWS ONLY"
56
+ assert.Equal(t, expectedSql, sql)
57
+
58
+ expectedArgs := []interface{}{0, 1, 2, 3, 100, 101, 102, 103, 4, 5, 6, 7, 8, 9, 10, 11, 1, 14}
59
+ assert.Equal(t, expectedArgs, args)
60
+ }
61
+
62
+ func TestSelectBuilderFromSelect(t *testing.T) {
63
+ subQ := Select("c").From("d").Where(Eq{"i": 0})
64
+ b := Select("a", "b").FromSelect(subQ, "subq")
65
+ sql, args, err := b.ToSql()
66
+ assert.NoError(t, err)
67
+
68
+ expectedSql := "SELECT a, b FROM (SELECT c FROM d WHERE i = ?) AS subq"
69
+ assert.Equal(t, expectedSql, sql)
70
+
71
+ expectedArgs := []interface{}{0}
72
+ assert.Equal(t, expectedArgs, args)
73
+ }
74
+
75
+ func TestSelectBuilderFromSelectNestedDollarPlaceholders(t *testing.T) {
76
+ subQ := Select("c").
77
+ From("t").
78
+ Where(Gt{"c": 1}).
79
+ PlaceholderFormat(Dollar)
80
+ b := Select("c").
81
+ FromSelect(subQ, "subq").
82
+ Where(Lt{"c": 2}).
83
+ PlaceholderFormat(Dollar)
84
+ sql, args, err := b.ToSql()
85
+ assert.NoError(t, err)
86
+
87
+ expectedSql := "SELECT c FROM (SELECT c FROM t WHERE c > $1) AS subq WHERE c < $2"
88
+ assert.Equal(t, expectedSql, sql)
89
+
90
+ expectedArgs := []interface{}{1, 2}
91
+ assert.Equal(t, expectedArgs, args)
92
+ }
93
+
94
+ func TestSelectBuilderToSqlErr(t *testing.T) {
95
+ _, _, err := Select().From("x").ToSql()
96
+ assert.Error(t, err)
97
+ }
98
+
99
+ func TestSelectBuilderPlaceholders(t *testing.T) {
100
+ b := Select("test").Where("x = ? AND y = ?")
101
+
102
+ sql, _, _ := b.PlaceholderFormat(Question).ToSql()
103
+ assert.Equal(t, "SELECT test WHERE x = ? AND y = ?", sql)
104
+
105
+ sql, _, _ = b.PlaceholderFormat(Dollar).ToSql()
106
+ assert.Equal(t, "SELECT test WHERE x = $1 AND y = $2", sql)
107
+
108
+ sql, _, _ = b.PlaceholderFormat(Colon).ToSql()
109
+ assert.Equal(t, "SELECT test WHERE x = :1 AND y = :2", sql)
110
+
111
+ sql, _, _ = b.PlaceholderFormat(AtP).ToSql()
112
+ assert.Equal(t, "SELECT test WHERE x = @p1 AND y = @p2", sql)
113
+ }
114
+
115
+ func TestSelectBuilderRunners(t *testing.T) {
116
+ db := &DBStub{}
117
+ b := Select("test").RunWith(db)
118
+
119
+ expectedSql := "SELECT test"
120
+
121
+ b.Exec()
122
+ assert.Equal(t, expectedSql, db.LastExecSql)
123
+
124
+ b.Query()
125
+ assert.Equal(t, expectedSql, db.LastQuerySql)
126
+
127
+ b.QueryRow()
128
+ assert.Equal(t, expectedSql, db.LastQueryRowSql)
129
+
130
+ err := b.Scan()
131
+ assert.NoError(t, err)
132
+ }
133
+
134
+ func TestSelectBuilderNoRunner(t *testing.T) {
135
+ b := Select("test")
136
+
137
+ _, err := b.Exec()
138
+ assert.Equal(t, RunnerNotSet, err)
139
+
140
+ _, err = b.Query()
141
+ assert.Equal(t, RunnerNotSet, err)
142
+
143
+ err = b.Scan()
144
+ assert.Equal(t, RunnerNotSet, err)
145
+ }
146
+
147
+ func TestSelectBuilderSimpleJoin(t *testing.T) {
148
+
149
+ expectedSql := "SELECT * FROM bar JOIN baz ON bar.foo = baz.foo"
150
+ expectedArgs := []interface{}(nil)
151
+
152
+ b := Select("*").From("bar").Join("baz ON bar.foo = baz.foo")
153
+
154
+ sql, args, err := b.ToSql()
155
+ assert.NoError(t, err)
156
+
157
+ assert.Equal(t, expectedSql, sql)
158
+ assert.Equal(t, args, expectedArgs)
159
+ }
160
+
161
+ func TestSelectBuilderParamJoin(t *testing.T) {
162
+
163
+ expectedSql := "SELECT * FROM bar JOIN baz ON bar.foo = baz.foo AND baz.foo = ?"
164
+ expectedArgs := []interface{}{42}
165
+
166
+ b := Select("*").From("bar").Join("baz ON bar.foo = baz.foo AND baz.foo = ?", 42)
167
+
168
+ sql, args, err := b.ToSql()
169
+ assert.NoError(t, err)
170
+
171
+ assert.Equal(t, expectedSql, sql)
172
+ assert.Equal(t, args, expectedArgs)
173
+ }
174
+
175
+ func TestSelectBuilderNestedSelectJoin(t *testing.T) {
176
+
177
+ expectedSql := "SELECT * FROM bar JOIN ( SELECT * FROM baz WHERE foo = ? ) r ON bar.foo = r.foo"
178
+ expectedArgs := []interface{}{42}
179
+
180
+ nestedSelect := Select("*").From("baz").Where("foo = ?", 42)
181
+
182
+ b := Select("*").From("bar").JoinClause(nestedSelect.Prefix("JOIN (").Suffix(") r ON bar.foo = r.foo"))
183
+
184
+ sql, args, err := b.ToSql()
185
+ assert.NoError(t, err)
186
+
187
+ assert.Equal(t, expectedSql, sql)
188
+ assert.Equal(t, args, expectedArgs)
189
+ }
190
+
191
+ func TestSelectWithOptions(t *testing.T) {
192
+ sql, _, err := Select("*").From("foo").Distinct().Options("SQL_NO_CACHE").ToSql()
193
+
194
+ assert.NoError(t, err)
195
+ assert.Equal(t, "SELECT DISTINCT SQL_NO_CACHE * FROM foo", sql)
196
+ }
197
+
198
+ func TestSelectWithRemoveLimit(t *testing.T) {
199
+ sql, _, err := Select("*").From("foo").Limit(10).RemoveLimit().ToSql()
200
+
201
+ assert.NoError(t, err)
202
+ assert.Equal(t, "SELECT * FROM foo", sql)
203
+ }
204
+
205
+ func TestSelectWithRemoveOffset(t *testing.T) {
206
+ sql, _, err := Select("*").From("foo").Offset(10).RemoveOffset().ToSql()
207
+
208
+ assert.NoError(t, err)
209
+ assert.Equal(t, "SELECT * FROM foo", sql)
210
+ }
211
+
212
+ func TestSelectBuilderNestedSelectDollar(t *testing.T) {
213
+ nestedBuilder := StatementBuilder.PlaceholderFormat(Dollar).Select("*").Prefix("NOT EXISTS (").
214
+ From("bar").Where("y = ?", 42).Suffix(")")
215
+ outerSql, _, err := StatementBuilder.PlaceholderFormat(Dollar).Select("*").
216
+ From("foo").Where("x = ?").Where(nestedBuilder).ToSql()
217
+
218
+ assert.NoError(t, err)
219
+ assert.Equal(t, "SELECT * FROM foo WHERE x = $1 AND NOT EXISTS ( SELECT * FROM bar WHERE y = $2 )", outerSql)
220
+ }
221
+
222
+ func TestSelectBuilderMustSql(t *testing.T) {
223
+ defer func() {
224
+ if r := recover(); r == nil {
225
+ t.Errorf("TestSelectBuilderMustSql should have panicked!")
226
+ }
227
+ }()
228
+ // This function should cause a panic
229
+ Select().From("foo").MustSql()
230
+ }
231
+
232
+ func TestSelectWithoutWhereClause(t *testing.T) {
233
+ sql, _, err := Select("*").From("users").ToSql()
234
+ assert.NoError(t, err)
235
+ assert.Equal(t, "SELECT * FROM users", sql)
236
+ }
237
+
238
+ func TestSelectWithNilWhereClause(t *testing.T) {
239
+ sql, _, err := Select("*").From("users").Where(nil).ToSql()
240
+ assert.NoError(t, err)
241
+ assert.Equal(t, "SELECT * FROM users", sql)
242
+ }
243
+
244
+ func TestSelectWithEmptyStringWhereClause(t *testing.T) {
245
+ sql, _, err := Select("*").From("users").Where("").ToSql()
246
+ assert.NoError(t, err)
247
+ assert.Equal(t, "SELECT * FROM users", sql)
248
+ }
249
+
250
+ func TestSelectSubqueryPlaceholderNumbering(t *testing.T) {
251
+ subquery := Select("a").Where("b = ?", 1).PlaceholderFormat(Dollar)
252
+ with := subquery.Prefix("WITH a AS (").Suffix(")")
253
+
254
+ sql, args, err := Select("*").
255
+ PrefixExpr(with).
256
+ FromSelect(subquery, "q").
257
+ Where("c = ?", 2).
258
+ PlaceholderFormat(Dollar).
259
+ ToSql()
260
+ assert.NoError(t, err)
261
+
262
+ expectedSql := "WITH a AS ( SELECT a WHERE b = $1 ) SELECT * FROM (SELECT a WHERE b = $2) AS q WHERE c = $3"
263
+ assert.Equal(t, expectedSql, sql)
264
+ assert.Equal(t, []interface{}{1, 1, 2}, args)
265
+ }
266
+
267
+ func TestSelectSubqueryInConjunctionPlaceholderNumbering(t *testing.T) {
268
+ subquery := Select("a").Where(Eq{"b": 1}).Prefix("EXISTS(").Suffix(")").PlaceholderFormat(Dollar)
269
+
270
+ sql, args, err := Select("*").
271
+ Where(Or{subquery}).
272
+ Where("c = ?", 2).
273
+ PlaceholderFormat(Dollar).
274
+ ToSql()
275
+ assert.NoError(t, err)
276
+
277
+ expectedSql := "SELECT * WHERE (EXISTS( SELECT a WHERE b = $1 )) AND c = $2"
278
+ assert.Equal(t, expectedSql, sql)
279
+ assert.Equal(t, []interface{}{1, 2}, args)
280
+ }
281
+
282
+ func TestSelectJoinClausePlaceholderNumbering(t *testing.T) {
283
+ subquery := Select("a").Where(Eq{"b": 2}).PlaceholderFormat(Dollar)
284
+
285
+ sql, args, err := Select("t1.a").
286
+ From("t1").
287
+ Where(Eq{"a": 1}).
288
+ JoinClause(subquery.Prefix("JOIN (").Suffix(") t2 ON (t1.a = t2.a)")).
289
+ PlaceholderFormat(Dollar).
290
+ ToSql()
291
+ assert.NoError(t, err)
292
+
293
+ expectedSql := "SELECT t1.a FROM t1 JOIN ( SELECT a WHERE b = $1 ) t2 ON (t1.a = t2.a) WHERE a = $2"
294
+ assert.Equal(t, expectedSql, sql)
295
+ assert.Equal(t, []interface{}{2, 1}, args)
296
+ }
297
+
298
+ func ExampleSelect() {
299
+ Select("id", "created", "first_name").From("users") // ... continue building up your query
300
+
301
+ // sql methods in select columns are ok
302
+ Select("first_name", "count(*)").From("users")
303
+
304
+ // column aliases are ok too
305
+ Select("first_name", "count(*) as n_users").From("users")
306
+ }
307
+
308
+ func ExampleSelectBuilder_From() {
309
+ Select("id", "created", "first_name").From("users") // ... continue building up your query
310
+ }
311
+
312
+ func ExampleSelectBuilder_Where() {
313
+ companyId := 20
314
+ Select("id", "created", "first_name").From("users").Where("company = ?", companyId)
315
+ }
316
+
317
+ func ExampleSelectBuilder_Where_helpers() {
318
+ companyId := 20
319
+
320
+ Select("id", "created", "first_name").From("users").Where(Eq{
321
+ "company": companyId,
322
+ })
323
+
324
+ Select("id", "created", "first_name").From("users").Where(GtOrEq{
325
+ "created": time.Now().AddDate(0, 0, -7),
326
+ })
327
+
328
+ Select("id", "created", "first_name").From("users").Where(And{
329
+ GtOrEq{
330
+ "created": time.Now().AddDate(0, 0, -7),
331
+ },
332
+ Eq{
333
+ "company": companyId,
334
+ },
335
+ })
336
+ }
337
+
338
+ func ExampleSelectBuilder_Where_multiple() {
339
+ companyId := 20
340
+
341
+ // multiple where's are ok
342
+
343
+ Select("id", "created", "first_name").
344
+ From("users").
345
+ Where("company = ?", companyId).
346
+ Where(GtOrEq{
347
+ "created": time.Now().AddDate(0, 0, -7),
348
+ })
349
+ }
350
+
351
+ func ExampleSelectBuilder_FromSelect() {
352
+ usersByCompany := Select("company", "count(*) as n_users").From("users").GroupBy("company")
353
+ query := Select("company.id", "company.name", "users_by_company.n_users").
354
+ FromSelect(usersByCompany, "users_by_company").
355
+ Join("company on company.id = users_by_company.company")
356
+
357
+ sql, _, _ := query.ToSql()
358
+ fmt.Println(sql)
359
+
360
+ // Output: SELECT company.id, company.name, users_by_company.n_users FROM (SELECT company, count(*) as n_users FROM users GROUP BY company) AS users_by_company JOIN company on company.id = users_by_company.company
361
+ }
362
+
363
+ func ExampleSelectBuilder_Columns() {
364
+ query := Select("id").Columns("created", "first_name").From("users")
365
+
366
+ sql, _, _ := query.ToSql()
367
+ fmt.Println(sql)
368
+ // Output: SELECT id, created, first_name FROM users
369
+ }
370
+
371
+ func ExampleSelectBuilder_Columns_order() {
372
+ // out of order is ok too
373
+ query := Select("id").Columns("created").From("users").Columns("first_name")
374
+
375
+ sql, _, _ := query.ToSql()
376
+ fmt.Println(sql)
377
+ // Output: SELECT id, created, first_name FROM users
378
+ }
379
+
380
+ func ExampleSelectBuilder_Scan() {
381
+
382
+ var db *sql.DB
383
+
384
+ query := Select("id", "created", "first_name").From("users")
385
+ query = query.RunWith(db)
386
+
387
+ var id int
388
+ var created time.Time
389
+ var firstName string
390
+
391
+ if err := query.Scan(&id, &created, &firstName); err != nil {
392
+ log.Println(err)
393
+ return
394
+ }
395
+ }
396
+
397
+ func ExampleSelectBuilder_ScanContext() {
398
+
399
+ var db *sql.DB
400
+
401
+ query := Select("id", "created", "first_name").From("users")
402
+ query = query.RunWith(db)
403
+
404
+ var id int
405
+ var created time.Time
406
+ var firstName string
407
+
408
+ if err := query.ScanContext(ctx, &id, &created, &firstName); err != nil {
409
+ log.Println(err)
410
+ return
411
+ }
412
+ }
413
+
414
+ func ExampleSelectBuilder_RunWith() {
415
+
416
+ var db *sql.DB
417
+
418
+ query := Select("id", "created", "first_name").From("users").RunWith(db)
419
+
420
+ var id int
421
+ var created time.Time
422
+ var firstName string
423
+
424
+ if err := query.Scan(&id, &created, &firstName); err != nil {
425
+ log.Println(err)
426
+ return
427
+ }
428
+ }
429
+
430
+ func ExampleSelectBuilder_ToSql() {
431
+
432
+ var db *sql.DB
433
+
434
+ query := Select("id", "created", "first_name").From("users")
435
+
436
+ sql, args, err := query.ToSql()
437
+ if err != nil {
438
+ log.Println(err)
439
+ return
440
+ }
441
+
442
+ rows, err := db.Query(sql, args...)
443
+ if err != nil {
444
+ log.Println(err)
445
+ return
446
+ }
447
+
448
+ defer rows.Close()
449
+
450
+ for rows.Next() {
451
+ // scan...
452
+ }
453
+ }
454
+
455
+ func TestRemoveColumns(t *testing.T) {
456
+ query := Select("id").
457
+ From("users").
458
+ RemoveColumns()
459
+ query = query.Columns("name")
460
+ sql, _, err := query.ToSql()
461
+ assert.NoError(t, err)
462
+ assert.Equal(t, "SELECT name FROM users", sql)
463
+ }