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

Cannot query a Postgres database from Restroom #193

Open
sargue opened this issue Jul 5, 2022 · 1 comment
Open

Cannot query a Postgres database from Restroom #193

sargue opened this issue Jul 5, 2022 · 1 comment
Assignees

Comments

@sargue
Copy link

sargue commented Jul 5, 2022

I'm testing the db middleware and trying to perform a simple SQL query to a Postgres database.

This is the code:

Rule check version 2.0.0
Rule caller restroom-mw

Given I have a 'string' named 'myResult'
Given I have a database uri named 'postgres'
Given I execute the SQL statement named 'sql' on the database named 'postgres' and save the result into 'myResult'

Then print 'myResult'

This are the keys:

{
    "postgres": "postgres://postgres:pgsecret@postgres:5432/postgres",
    "sql": "SELECT * FROM token_transfers;"
}

And this is the output:
{
"zenroom_errors": {
"result": "",
"logs": " . Release version: 2.0.0\n . Build commit hash: 3144ca24\n . ECDH curve is SECP256K1\n . ECP curve is BLS381\n . Memory in use: 413 KB\n . Zencode version match: 2.0.0\n . Rule check version 2.0.0\n . Rule caller restroom-mw\n[W] Zencode pattern ignored: Given I have a database uri named 'postgres'\t1\n[W] Zencode pattern ignored: Given I execute the SQL statement named 'sql' on the database named postgres¡ and save the result into 'myResult'\t1\n[W] Given I have a 'string' named 'myResult'\t2\n[W] nil\n[W] [!] /zencode_given.lua:301: Cannot find 'myResult' anywhere (null value?)\n[W] {\n a_GIVEN_in = {},\n b_GIVEN_in = {\n postgres = "postgres://postgres:pgsecret@postgres:5432/postgres",\n sql = "SELECT * FROM token_transfers;"\n },\n c_WHEN_ack = {},\n d_THEN_out = {}\n}\n[!] ERROR:\n[!] EXEC: /zencode.lua:630: Given I have a 'string' named 'myResult'\n[!] Execution aborted\n[!] Error detected. Execution aborted.\n[*] Zenroom teardown.\n . Memory used: 431 KB\n"
},
"result": "",
"exception": "[ZENROOM EXECUTION ERROR FOR CONTRACT test]\n\n\n Please check zenroom_errors logs"
}

This is running Restroom using a Docker image defined like this:

FROM node:16-alpine

# Add dependencies
RUN apk add git python3 make g++

# Installing restroom
RUN yarn global add create-restroom@next
RUN create-restroom --all restroom-mw
WORKDIR /restroom-mw
RUN yarn add @restroom-mw/[email protected] --save

COPY contracts contracts
COPY keys keys

# Configure restroom
ENV CUSTOM_404_MESSAGE="nothing to see here"
ENV HTTP_PORT=3300
ENV HTTPS_PORT=3301
ENV OPENAPI=true
ENV ZENCODE_DIR=./contracts
ENV KEYS_DIR=./keys
ENV CHAIN_EXT=chain
ENV YML_EXT=yml

EXPOSE 3300/tcp

CMD yarn start
@puria
Copy link
Member

puria commented Jul 7, 2022

Hi @sargue,
thanks for the feedback, will look at it ;)

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

2 participants