Skip to content

Commit 92ff16d

Browse files
committed
chore: remove "limit" query parameter from get_list in order to make integration tests pass
Partically reverts changes from f524f15 commit. Reopen #23 Part of #13 Relate to #41
1 parent 3238fe8 commit 92ff16d

File tree

5 files changed

+7
-21
lines changed

5 files changed

+7
-21
lines changed

examples/go/chi/mysql/routes.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,8 @@ func registerRoutes(r chi.Router, db *sqlx.DB) {
7777
})
7878

7979
r.Get("/v1/categories", func(w http.ResponseWriter, r *http.Request) {
80-
stmt, err := db.PrepareNamed("SELECT id , name , name_ru , slug FROM categories LIMIT :limit")
81-
if err != nil {
82-
fmt.Fprintf(os.Stderr, "PrepareNamed failed: %v\n", err)
83-
internalServerError(w)
84-
return
85-
}
86-
8780
result := []CategoryDto{}
88-
args := map[string]interface{}{
89-
"limit": r.URL.Query().Get("limit"),
90-
}
91-
err = stmt.Select(&result, args)
81+
err := db.Select(&result, "SELECT id , name , name_ru , slug FROM categories")
9282
switch err {
9383
case sql.ErrNoRows:
9484
w.WriteHeader(http.StatusNotFound)

examples/js/express/mysql/endpoints.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
, name
3838
, name_ru
3939
, slug
40-
FROM categories
41-
LIMIT :q.limit
40+
FROM categories
4241
dto:
4342
name: CategoryDto
4443
fields:

examples/js/express/mysql/routes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ const register = (app, pool) => {
3535

3636
app.get('/v1/categories', (req, res, next) => {
3737
pool.query(
38-
'SELECT id , name , name_ru , slug FROM categories LIMIT :limit',
39-
{ "limit": req.query.limit },
38+
'SELECT id , name , name_ru , slug FROM categories',
4039
(err, rows, fields) => {
4140
if (err) {
4241
return next(err)

examples/python/fastapi/postgres/routes.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_v1_collections_collection_id_categories_count(collectionId, conn=Depends
7373

7474

7575
@router.get('/v1/categories')
76-
def get_list_v1_categories(limit, conn=Depends(db_connection)):
76+
def get_list_v1_categories(conn=Depends(db_connection)):
7777
try:
7878
with conn:
7979
with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur:
@@ -83,9 +83,8 @@ def get_list_v1_categories(limit, conn=Depends(db_connection)):
8383
, name
8484
, name_ru
8585
, slug
86-
FROM categories
87-
LIMIT %(limit)s
88-
""", {"limit": limit})
86+
FROM categories
87+
""")
8988
return cur.fetchall()
9089
finally:
9190
conn.close()

examples/ts/express/mysql/routes.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ const register = (app: Express, pool: Pool) => {
3838

3939
app.get('/v1/categories', (req: Request, res: Response, next: NextFunction) => {
4040
pool.query(
41-
'SELECT id , name , name_ru , slug FROM categories LIMIT :limit',
42-
{ "limit": req.query.limit },
41+
'SELECT id , name , name_ru , slug FROM categories',
4342
(err, rows, fields) => {
4443
if (err) {
4544
return next(err)

0 commit comments

Comments
 (0)