amplify-js: Filters doesn't return any data when using numbers.
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
System:
OS: macOS 14.4.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.60 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
pnpm: 8.7.0 - /opt/homebrew/bin/pnpm
bun: 1.0.23 - ~/.bun/bin/bun
Browsers:
Chrome: 124.0.6367.201
Safari: 17.4.1
npmPackages:
@aws-amplify/react-native: ^1.0.28 => 1.0.28
@babel/core: ^7.20.0 => 7.24.4
@expo/vector-icons: ^14.0.0 => 14.0.0
@hookform/resolvers: ^3.3.4 => 3.3.4
@hookform/resolvers/ajv: 1.0.0
@hookform/resolvers/arktype: 1.0.0
@hookform/resolvers/class-validator: 1.0.0
@hookform/resolvers/computed-types: 1.0.0
@hookform/resolvers/io-ts: 1.0.0
@hookform/resolvers/joi: 1.0.0
@hookform/resolvers/nope: 1.0.0
@hookform/resolvers/superstruct: 1.0.0
@hookform/resolvers/typanion: 1.0.0
@hookform/resolvers/typebox: 1.0.0
@hookform/resolvers/valibot: 1.0.0
@hookform/resolvers/vest: 1.0.0
@hookform/resolvers/yup: 1.0.0
@hookform/resolvers/zod: 1.0.0
@react-native-async-storage/async-storage: 1.21.0 => 1.21.0
@react-native-community/datetimepicker: 7.6.1 => 7.6.1
@react-native-community/netinfo: 11.1.0 => 11.1.0
@react-native-picker/picker: 2.6.1 => 2.6.1
@react-navigation/native: ^6.0.2 => 6.1.17
@types/numeral: ^2.0.5 => 2.0.5
@types/react: ~18.2.45 => 18.2.79
HelloWorld: 0.0.1
aws-amplify: ^6.0.30 => 6.0.30
aws-amplify/adapter-core: undefined ()
aws-amplify/analytics: undefined ()
aws-amplify/analytics/kinesis: undefined ()
aws-amplify/analytics/kinesis-firehose: undefined ()
aws-amplify/analytics/personalize: undefined ()
aws-amplify/analytics/pinpoint: undefined ()
aws-amplify/api: undefined ()
aws-amplify/api/server: undefined ()
aws-amplify/auth: undefined ()
aws-amplify/auth/cognito: undefined ()
aws-amplify/auth/cognito/server: undefined ()
aws-amplify/auth/enable-oauth-listener: undefined ()
aws-amplify/auth/server: undefined ()
aws-amplify/data: undefined ()
aws-amplify/data/server: undefined ()
aws-amplify/datastore: undefined ()
aws-amplify/in-app-messaging: undefined ()
aws-amplify/in-app-messaging/pinpoint: undefined ()
aws-amplify/push-notifications: undefined ()
aws-amplify/push-notifications/pinpoint: undefined ()
aws-amplify/storage: undefined ()
aws-amplify/storage/s3: undefined ()
aws-amplify/storage/s3/server: undefined ()
aws-amplify/storage/server: undefined ()
aws-amplify/utils: undefined ()
expo: ~50.0.14 => 50.0.17
expo-dev-client: ~3.3.11 => 3.3.11
expo-font: ~11.10.3 => 11.10.3
expo-image: ~1.10.6 => 1.10.6
expo-image-picker: ~14.7.1 => 14.7.1
expo-linear-gradient: ~12.7.2 => 12.7.2
expo-linking: ~6.2.2 => 6.2.2
expo-location: ~16.5.5 => 16.5.5
expo-router: ~3.4.8 => 3.4.8
expo-splash-screen: ~0.26.4 => 0.26.4
expo-status-bar: ~1.11.1 => 1.11.1
expo-system-ui: ~2.9.3 => 2.9.4
expo-web-browser: ~12.8.2 => 12.8.2
lucide-react-native: ^0.372.0 => 0.372.0
moment: ^2.30.1 => 2.30.1
numeral: ^2.0.6 => 2.0.6
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-hook-form: ^7.51.3 => 7.51.3
react-native: 0.73.6 => 0.73.6
react-native-gesture-handler: ~2.14.1 => 2.14.1
react-native-get-random-values: ~1.8.0 => 1.8.0
react-native-google-places-autocomplete: ^2.5.6 => 2.5.6
react-native-mask-input: ^1.2.3 => 1.2.3
react-native-otp-entry: ^1.6.1 => 1.6.1
react-native-reanimated: ~3.6.2 => 3.6.3
react-native-reanimated-carousel: ^3.5.1 => 3.5.1
react-native-safe-area-context: 4.8.2 => 4.8.2
react-native-screens: ~3.29.0 => 3.29.0
react-native-svg: 14.1.0 => 14.1.0
react-native-svg-transformer: ^1.3.0 => 1.3.0
react-native-web: ~0.19.6 => 0.19.10
react-native-woodpicker: ^0.3.17 => 0.3.17
typescript: ^5.1.3 => 5.4.5
zod: ^3.23.4 => 3.23.4
zustand: ^4.5.2 => 4.5.2
npmGlobalPackages:
corepack: 0.18.0
npm: 9.6.7
Describe the bug
I’m trying to get all the records in my db filtering by lat and lng, (Float fields) I have a range for each field (lat, lng)
This is my query statement:
const { data } = await client.graphql({
query: listAffiliates,
variables: {
filter: {
and: [
{
lat: {
between: [
minLat,
maxLat,
]
}
},
{
lng: {
between: [
minLng,
maxLng,
]
}
},
]
}
}
});
Even doing this doesn’t seems to work:
lat: {
eq: 36.77676,
}
My data without any filtering is this one so it should work:
[{"__typename": "Affiliate", "address": "***", "businessHours": "{\"monday\":{\"from\":\"09:00 am\",\"to\":\"07:00 pm\"}}", "category": null, "coupons": {"items": [Array]}, "coverPicture": null, "createdAt": "2024-04-30T04:39:21.263Z", "description": "Cenaduría", "id": "218b239b-42ee-4392-8a42-c38008c2201f", "lat": 36.77676, "lng": -115.56526, "name": "Tortas La Panzona", "profilePicture": "profile-picture/a4a88488-b041-70ed-e1ff-127fd80eea4d_6350A80E-0A3F-49A5-8774-09FD97F5BB86.jpg", "reviews": {"items": [Array]}, "updatedAt": "2024-04-30T04:46:31.671Z", "userId": "a4a88488-b041-70ed-e1ff-127fd80eea4d"}, {"__typename": "Affiliate", "address": "***", "businessHours": "{\"monday\":{\"from\":\"11:00 am\",\"to\":\"12:00 pm\"},\"tuesday\":{\"from\":\"11:00 am\",\"to\":\"12:00 pm\"},\"thursday\":{\"from\":\"09:00 am\",\"to\":\"11:00 pm\"},\"Lunes\":{\"from\":\"10:00 am\",\"to\":\"04:00 pm\"}}", "category": "Restaurante Bar", "coupons": {"items": [Array]}, "coverPicture": "cover-picture/14784418-40e1-703f-6058-37f638350ebf_0AC2B4A9-DDBD-4E4D-AFF4-1442A5877843.jpg", "createdAt": "2024-04-30T04:31:08.823Z", "description": "Cenaduría", "id": "17989f6d-2e5f-49a9-b529-f55d894cc496", "lat": 36.77676, "lng": -115.56526, "name": "Tortas El Panzón", "profilePicture": "profile-picture/14784418-40e1-703f-6058-37f638350ebf_959090CF-944A-4363-B042-975373E3AB60.jpg", "reviews": {"items": [Array]}, "updatedAt": "2024-05-10T23:36:32.447Z", "userId": "14784418-40e1-703f-6058-37f638350ebf"}]
Expected behavior
Filter the records in my db in order to get the nearest to the user.
Reproduction steps
- initialize a new amplify project.
- create a model with a Int field.
- create a record for this model and enter a negative number in this numeric field
- try to filter this record by its numeric field using a couple negative values.
- face the error.
Code Snippet
// Put your code below this line.
const { data } = await client.graphql({
query: listAffiliates,
variables: {
filter: {
and: [
{
lat: {
between: [
minLat,
maxLat,
]
}
},
{
lng: {
between: [
minLng,
maxLng,
]
}
},
]
}
}
});
GraphQL model
type Affiliate @model {
id: ID!
name: String!
lat: Float! @index
lng: Float! @index
...other fields
}
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
Iphone 15 pro Simulator
Mobile Operating System
IOS 17.4
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (7 by maintainers)
Hi @fimbres apologies for the wait. We haven’t been able to reproduce this issue internally.
If you’re still experiencing this issue I would try testing the same query in the AppSync console and see if you get the same behavior and also in the DynamoDB console. This would rule out whether it’s an issue with Amplify’s resolvers, library, or if the issue is occurring at the database level.
Might also be worth trying to reproduce on a fresh project.
Can you check the network activity in your browser, search for the
graphqlrequest in the Network tab, and share the payload that was sent? Just want to be certain of the values being passed for the filter expression.Hi @fimbres I deployed the same schema but I don’t think I ran into any issues while trying to query and filter using numbers.
Here’s my first query:
and the result:
I changed the
latfilter to:and the result was no data, as expected:
Also doing eq seems to work:
Same result as first query.
Can you share more details about the values you’re using to filter for records?
Hi, @fimbres 👋 Sorry for the delayed response. Thank you for raising this issue!
I will be reproducing this issue and report back soon to mark as a bug or explain any findings