Closed Brambo27 closed 3 months ago
Intresting, could you create a repo?
Yes, here you go: https://github.com/Brambo27/reporting Let me know if you need anything else, thanks.
Could you also add a small seed etc/database? So I can just run the docker-compose up
and start the API to test? Then I can take a quick look to see without needing to first setup database and insert data etc.
Yes of course.
Just as I was setting up the repo, I figured I'd check if the issue was the database just to be sure. We're actually using an aws redshift database but we're connecting with psql. Just now I tried to see if it worked with just a normal psql database and yes that all works as expected, so I guess that's the issue.
I would still love to get this working with redshift but I don't think I can provide you with a redshift test database. Do you have any ideas?
Thanks already for your time.
Just to be sure:
For both the redshift and Postgres db the query that gets executed is the same, I'm not sure if the data is returned correctly, I don't know how I can check this in typeorm or nestjs-query.
This is the query that runs:
SELECT "Order"."uuid" AS "Order_uuid", "Order"."client_uuid" AS "Order_client_uuid", "Order"."currency" AS "Order_currency", "Order"."note" AS "Order_note", "Order"."incoterms" AS "Order_incoterms", "Order"."special_details" AS "Order_special_details", "Order"."packing_instructions" AS "Order_packing_instructions", "Order"."special_instructions" AS "Order_special_instructions", "Order"."reference" AS "Order_reference", "Order"."source_identifier" AS "Order_source_identifier", "Order"."source_name" AS "Order_source_name", "Order"."source_url" AS "Order_source_url", "Order"."subtotal_price" AS "Order_subtotal_price", "Order"."status" AS "Order_status", "Order"."tax_lines" AS "Order_tax_lines", "Order"."total_discounts" AS "Order_total_discounts", "Order"."total_order_lines_price" AS "Order_total_order_lines_price", "Order"."shipping_price" AS "Order_shipping_price", "Order"."total_price" AS "Order_total_price", "Order"."total_tax" AS "Order_total_tax", "Order"."billing_address" AS "Order_billing_address", "Order"."shipping_address" AS "Order_shipping_address", "Order"."created_at" AS "Order_created_at", "Order"."updated_at" AS "Order_updated_at", "Order"."shipping_preference" AS "Order_shipping_preference" FROM "orders"
Running the same query via psql in the terminal for both Redshift and Postgres databases there is one difference, the redshift seems to ignore the capitalisation of the AS command:
Redshift: order_uuid | order_client_uuid | order_currency | order_note | order_incoterms | ...
Postgres: Order_uuid | Order_client_uuid | Order_currency | Order_note | Order_incoterms | ...
I'm guessing that makes it so typeorm or nestjs-query can't map it to an entity? I will see if i can set enable_case_sensitive_identifier on the redshift and see if that fixes it.
Confirmed setting enable_case_sensitive_identifier
to true on redshift made everything behave like expected. Thank you for pointing me in the right direction and for the awesome library :)
Hi, I'm facing an issue with the query method (and subsequently the entire graphql endpoint). I'm expecting
this.orderService.query({})
to return all records but it returns empty array. Usingthis.orderService.count({})
does return correct number of records.I was having the same issue with just typescript but that was fixed by adding the table name 'orders' into createQueryBuilder like so:
this.orderRepository.createQueryBuilder('orders').getMany().then((orders) => console.log(orders));
Observed Behavior: this.orderService.query({}) returns an empty array []. this.orderService.count({}) returns 12.
Expected Behavior: this.orderService.query({}) should return an array of Order entities matching the number of records returned by the count.
Additional Context: Direct queries using TypeORM's repository return the correct data. Ensured TypeORM logging shows correct queries being executed, but nestjs-query appears not to map results correctly.
I'm having a hard time debugging this issue, as I'm not sure where to start to gain any insight on what is going on under the hood. If someone could point me in the right direction or help me identify what I'm doing wrong I would be grateful.
Table Schema: