mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-05-02 20:05:49 +03:00
[GH-ISSUE #112] does sandman2 query data support “>” "<" #59
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @abcweizhuo on GitHub (Jul 11, 2019).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/112
Environment
MySQL 8.0
sandman2 1.2.1
pymysql 0.9.3
Postman 7.2.2
Operating system: win7 x64
Description of issue
step1 create table and insert data
create database paspce ,create table t_areainfo , insert data to table.
like this
"create database if not exists pspace;
create table if not exists pspace.t_areainfo(
id int primary key,
level int,
name varchar(255),
parentId int,
status int
);
insert into pspace.t_areainfo values(1, 0, 'aaa', 0, 0),(2, 0, 'bbb', 1, 0),(3, 0, 'ccc', 1, 0),(4, 0, 'ddd', 2, 0);"
step2 start sandman2ctl then use postman query data
start sandman2ctl in cmd like this "sandman2ctl mysql+pymysql://admin:juan@localhost/pspace".
then use postman query data by get at this url "127.0.0.1:5000/t_areainfo/", it works well.
step3 query data by get and use "<"
query data by get at url "127.0.0.1:5000/t_areainfo/?id<3" reveive this message
"{
"message": "Invalid field [id<3]"
}"
is bug or not support?tell me thanks。
@abcweizhuo commented on GitHub (Jul 22, 2019):
#deal with key like '?id>1" elif len(value) == 0 and ('>' in key or '<' in key): if '>' in key: filterindex = key.find('>') keytmp = key[:filterindex] else: filterindex = key.find('<') keytmp = key[:filterindex] if hasattr(self.__model__, keytmp): if '>' in key: filters.append(getattr(self.__model__, keytmp) > key[filterindex+1:]) else: filters.append(getattr(self.__model__, keytmp) < key[filterindex+1:]) else: raise BadRequestException('Invalid field [{}]'.format(keytmp))in function _all_resources(self), add this ,i can deal with with key like '?id>1"