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

Fixing base and user objects #1323

Merged
merged 10 commits into from
Jul 2, 2015

Conversation

josenavas
Copy link
Contributor

This fixes the base and user object to use the transaction.

Since this is the first time the transaction object is used in the code base, I will appreciate if people can take a quick look to see that everything works as expected.

Thanks!

@josenavas josenavas added this to the Alpha 0.2 milestone Jul 2, 2015
@josenavas josenavas mentioned this pull request Jul 2, 2015
28 tasks
sql = """SELECT EXISTS(
SELECT * FROM qiita.{0}
WHERE {0}_id=%s)""".format(self._table)
TRN.add(sql, [id_])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am under the impression that these had to be tuples and that lists were interpreted in a very different way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, here we just need to pass an iterable so psycopg doesn't fail. It is weird but psycopg always requires an iterable as sql_args, even if there is a single element. Also, the transaction object forces this to be lists so it can do the placeholder replacements.

@ElDeveloper
Copy link
Member

This looks good overall, very simple changes and I like that you are reformatting the SQL to be structured in a consistent way, perhaps you should take some notes and add a section in the CONTRIBUTING.md file. Also minor note, would perhaps be good to have all SQL keywords be all-caps.

Other reviewers, these are very simple changes so it's quick to go through.

@josenavas
Copy link
Contributor Author

@ElDeveloper comments addressed!

@josenavas
Copy link
Contributor Author

Re: CONTRIBUTING.md, I've added another item to #1262

info = conn_handler.execute_fetchone(sql, (email, ))

# verify user email verification
# MAGIC NUMBER 5 = unverified email
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not your fault, but could you change this to use the new convert_to_id() function?

@squirrelo
Copy link
Contributor

👍

1 similar comment
@ElDeveloper
Copy link
Member

👍

ElDeveloper added a commit that referenced this pull request Jul 2, 2015
@ElDeveloper ElDeveloper merged commit f0a34fc into qiita-spots:transaction Jul 2, 2015
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

Successfully merging this pull request may close these issues.

3 participants