Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error in filtering with JSON columns #74

Closed
devashishsethia opened this issue Dec 8, 2019 · 2 comments
Closed

Error in filtering with JSON columns #74

devashishsethia opened this issue Dec 8, 2019 · 2 comments

Comments

@devashishsethia
Copy link

Hi,

I've an interesting bug annoying me for quite a few hours now. I have my users model which has a phone jsonb field. I've defined my Schema as follows:

static get jsonSchema() {
    return {
      type: 'object',
      required: ['role'],

      properties: {
        email: { type: ['string', 'null'] },
        password: {type:['string', 'null']},
        accountkitId: { type: ['string', 'null']},
        phone: {
          type: 'object',
          required: [],
          properties: {
            number: {type: 'string'},
            country_prefix: {type: 'string'},
            national_number: {type: 'string'}
          }
        },
        role: {type:'string', enum: ["rider", "driver", "employee"]},
        inviterId: {type:'integer'},
        cityId: {type:'integer'},
        isBlocked: {type:'boolean', default: false},
        isActive:{type:'boolean', default:false},
      }
    }
  }

now, with the following query, I get an error:

let user = await UserService.find({
          query: {
            phone: {
              number: '+919123456789'
            },
            $limit: 1
          }
        });

Error: select count(distinct(\"users\".\"id\")) as \"total\" from \"users\" where \"users\".\"phone\"#>'{number}' = $1 - invalid input syntax for type json"

If I omit the + before the query i.e. only use '919123456789' (which is actually present in my DB), it doesn't complain but doesn't give the correct result either. It just can't find the record.

let user = await UserService.find({
          query: {
            phone: {
              number: '919123456789''
            },
            $limit: 1
          }
        });

Please help as to what could be causing this and what can I do so that it just works. Thanks.

"objection": "^1.6.9",
"feathers-objection": "^4.2.3",

@devashishsethia
Copy link
Author

May be related to #62

@devashishsethia
Copy link
Author

Upgraded to the latest version (4.6.3) and works well. Closing the issue. For anyone else stumbling upon this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant