JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

PG::SyntaxError with Apartment gem

Aperta
#1,316 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Ruby
Stelle
2.3k
Fork
546
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

This issue is a (choose one):

  • Problem/bug report.
  • Feature request.
  • Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.

Checklist before submitting:

  • I've searched for an existing issue.
  • I've asked my question on Gitter and have not received a satisfactory answer.
  • I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
  • The feature I'm asking for is compliant with the JSON:API spec.

Description

  • Ruby 2.5.5
  • Rails 5.2
  • jsonapi-resources 0.10.2
Bug reports:

When using Apartment (multi-tenancy gem), any model that is shared among all tenants (i.e. in the 'public' schema) return an error 500 (PG::SyntaxError) when trying to query the API. This issue only happens with shared models, and not with tenant-specific models. The issue lies in the way jsonapi-resources writes its queries, e.g:

Internal Server Error: PG::SyntaxError: ERROR:  syntax error at or near "."
LINE 1: SELECT public.accounts.id AS public.accounts_id FROM "public...

The whole query is:

SELECT public.accounts.id AS public.accounts_id FROM "public"."accounts" WHERE "public"."accounts" = $1

SELECT public.accounts.id AS public.accounts_id FROM "public"."accounts" WHERE "public"."accounts" = $1

The bold part is the issue. There should be no dot in the AS statement. public.accounts_id should be public_accounts_id or just accounts_id.

This should be a trivial fix, but I just don't know where in the gem code queries are generated.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Non è indicato alcun file sorgente né alcun test. Inizia riproducendo la query di Apartment per gli shared models con le versioni indicate di Ruby, Rails e jsonapi-resources, quindi traccia la generazione della query che produce il SELECT mostrato. Il lavoro è completato quando l’alias generato non contiene più un punto e la query API dello shared model ha esito positivo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
postgresql, rails, ruby
Ambito
api, database
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.