-
Notifications
You must be signed in to change notification settings - Fork 92
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
postrgresql_query cannot handle .sql file with \n at end of file #180
Comments
@jtelcontar thanks for reporting this! Have you tried to use |
@Andersson007 Thanks for the suggestion! I just tested with When I was reading the Ansible documentation for the postgresql_query module (https://docs.ansible.com/ansible/latest/collections/community/postgresql/postgresql_query_module.html), it seemed like we should keep the value as |
@jtelcontar thanks for the feedback! Your issue has reminded me that we planned to set |
|
@Andersson007 Gotcha! Totally understandable. I think all of us have sources of pain in our projects. :) Thanks for replying. I'll definitely keep an eye on this issue. Let me know if you'd like me to test anything else. |
@jtelcontar hanks for offering help! Yes, it would be much appreciated. |
@Andersson007 Checking in to see if there are any updates on your end. No worries if not; let me know when would be a good time to circle back around to review any updates. Many thanks! |
@jtelcontar I've just put it in my todo for tomorrow morning. I'll investigate the situation and will propose something (probably several options) here to discuss among us (will ping our other contributors), thanks! :) |
Awesome, appreciate the info! I'll keep an eye out. :) |
cc @tcraxs @hunleyd @jtelcontar
The current implementation looks ugly - it's just an extra thing.
What's your opinion, folks? 1) or 2) ? I'm not in favor of any of them as I'm not a user and not an expert. If i had been able to implement the module again, i wouldn't have introduced |
As a user, I'd never equate Is it worth maybe down the road introducing a new module |
I'd personally prefer 1), as |
I agree that I do like the idea of separating out My only concern with option 1: are there implications of using |
Thank you folks! @jtelcontar if you use So we also have option 3 - a separate module called
So @hunleyd @DanScharon @jtelcontar @tcraxs questions are:
|
in addition to the above, if someone reviews #185, i could release 2.0.0 tomorrow provided that there are no objections |
+1
Those two seem to be the only ones needed IMHO
i prefer postgresql_script as the name (since foo.sql is a 'sql script' in my mind).
We need |
When we have
I'm not sure whether we should have this logic in
My painful experience is telling me that it's important to make right decisions now, on a design stage. Ideas? |
If there's a new module |
thx for the detailed write-up @Andersson007 , much appreciated. i now agree with @DanScharon 's comment above |
Could anyone please review the bugfix for this particular issue #192 ? |
@jtelcontar: Just to clarify, ANY text file SHOULD have a line break at the end of the file, i.e. the last line should be terminated properly (otherwise it's an "incomplete line"). It goes without saying that even a file with just one line should end with a line break. This is actually defined in the POSIX standards, see the POSIX definition of a Line - there is even a definition of an Incomplete Line. I have seen lots of software IDEs and editors which create text files without ensuring that the last line is terminated properly. Any good IDE or editor will have a setting to "ensure every saved file ends with a line break". |
SUMMARY
We are using a playbook task to run an SQL file that is generated by a PHP script. The PHP script uses
file_put_contents()
to create the .sql file based upon an array of queries (could be any number of queries). All queries end with a semicolon. The file is generated with a\n
at the end of the file every time, and there is no way to generate the file without it. Whenever I run the task, I receive a fatal error (Cannot execute SQL '' None: can't execute an empty query
). The only way to solve this is to open up the .sql file in an editor, delete the\n
character, and run the playbook again.I tried everything I can think of to attempt to trim that
\n
during the file generation, but no luck. Hoping you all can help or confirm this is a feature not a bug.ISSUE TYPE
COMPONENT NAME
postgresql_query
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Debian 10
PHP 7.4
Python 2.7 ( cannot upgrade to Python 3 yet on this server)
STEPS TO REPRODUCE
Generate a text file containing a couple of postgres queries in PHP with
file_put_contents()
. Open the file in an editor and note that it contains a new line at the end of the file.Run a playbook that contains the following simple task:
EXPECTED RESULTS
Task finishes with no fatal error and queries from our file have been run successfully.
ACTUAL RESULTS
The task fails with a fatal error due to the query list having a blank query in it.
(I've cleaned the resulting error message of our data.)
Thanks for any assistance you can offer!
The text was updated successfully, but these errors were encountered: