Skip to content

feat: allow comments by removing them #22

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

kirsanium
Copy link
Contributor

No description provided.

@php-coder
Copy link
Owner

php-coder commented Oct 6, 2022

Сходу не заработало:

diff --git examples/js/endpoints.yaml examples/js/endpoints.yaml
index 7d1d09a..163f902 100644
--- examples/js/endpoints.yaml
+++ examples/js/endpoints.yaml
@@ -18,6 +18,7 @@
 - path: /v1/collections/:collectionId/categories/count
   get:
     query: >-
+      -- SQL comments can be used but they won't be included in the resulted code
       SELECT COUNT(DISTINCT s.category_id) AS counter
         FROM collections_series cs
         JOIN series s
diff --git examples/js/routes.js examples/js/routes.js
index a6d39a3..043cf40 100644
--- examples/js/routes.js
+++ examples/js/routes.js
@@ -19,7 +19,7 @@ app.get('/v1/categories/count', (req, res) => {

 app.get('/v1/collections/:collectionId/categories/count', (req, res) => {
     pool.query(
-        'SELECT COUNT(DISTINCT s.category_id) AS counter FROM collections_series cs JOIN series s ON s.id = cs.series_id WHERE cs.collection_id = :collectionId',
+        '  FROM collections_series cs JOIN series s ON s.id = cs.series_id WHERE cs.collection_id = :collectionId',
         { "collectionId": req.params.collectionId },
         (err, rows, fields) => {
             if (err) {
diff --git examples/python/routes.py examples/python/routes.py
index 2035404..d36a06d 100644
--- examples/python/routes.py
+++ examples/python/routes.py
@@ -51,7 +51,7 @@ def get_v1_collections_collection_id_categories_count(collectionId, conn = Depen
     try:
         with conn:
             with conn.cursor(cursor_factory = psycopg2.extras.RealDictCursor) as cur:
-                cur.execute("SELECT COUNT(DISTINCT s.category_id) AS counter FROM collections_series cs JOIN series s ON s.id = cs.series_id WHERE cs.collection_id = %(collectionId)s", { "collectionId": collectionId })
+                cur.execute("  FROM collections_series cs JOIN series s ON s.id = cs.series_id WHERE cs.collection_id = %(collectionId)s", { "collectionId": collectionId })
                 result = cur.fetchone()
                 if result is None:
                     raise HTTPException(status_code=404)

@php-coder
Copy link
Owner

Проблема проявляется когда комментарий указан в начале, перед SQL-запросом -- почему-то после нее не добавляется перевод строки. Ок, тогда пока, оставляю PR открытым.

@kirsanium
Copy link
Contributor Author

kirsanium commented Oct 6, 2022

Можно использовать query: |- вместо query: >-.

JOIN series s
ON s.id = cs.series_id
WHERE cs.collection_id = :p.collectionId
WHERE cs.collection_id = :p.collectionId
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем это изменение?

@@ -42,7 +45,7 @@
id:
type: integer
post:
query: >-
query: |-
Copy link
Owner

@php-coder php-coder Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем везде менять понадобилось-то?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для наглядности, чтобы уменьшить шанс того, что кому-то придет в голову использовать >- с комментариями :)

Copy link
Owner

@php-coder php-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не надо править то, что не сломалось :)

@php-coder php-coder merged commit 131bca1 into php-coder:master Oct 10, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants