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

Set default value for Not Null Column in CRE.sql #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Set default value for Not Null Column in CRE.sql #3

wants to merge 1 commit into from

Conversation

revsi
Copy link

@revsi revsi commented Sep 15, 2016

No description provided.

@polybuildr
Copy link
Collaborator

polybuildr commented Sep 15, 2016

Thanks for the PR!

This seems weird. CRE.sql has

ALTER TABLE `candidates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

and then the insert code in admin/add_candidate.php says:

$query = mysqli_prepare($DB, "INSERT INTO `candidates` (name) VALUES (?)");
mysqli_stmt_bind_param($query, 's', $_POST["candidate_name"]);

We only set name, where do the votes and n_votes come from? Does MySQL default them to 0? /cc @nisargjhaveri @hharchani

Copy link
Collaborator

@polybuildr polybuildr left a comment

Choose a reason for hiding this comment

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

Aha, so it does default to 0. Thanks @hharchani.

@revsi, can you please update the commit message to match convention? Capital first letter, imperative tense of writing, etc.? Also, since @hharchani says it implicitly defaults to 0, maybe you can explicitly say: "Set default value of some fields in CRE.sql" or something like that?

@hharchani
Copy link
Collaborator

Yeah, it defaults to 0, but better to be explicit

@revsi
Copy link
Author

revsi commented Sep 15, 2016

I am not sure exactly. But for MySql V5.7, If strict SQL mode is enabled, an error occurs for transactional tables and the statement is rolled back in case of Not Null Column. In my case it was causing error.

@revsi revsi changed the title fixed issues with first time configuration Set default value for Not Null Column in CRE.sql Sep 15, 2016
Copy link
Collaborator

@polybuildr polybuildr left a comment

Choose a reason for hiding this comment

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

Ah, I see. That's interesting. It's certainly better to be explicit then. Will merge this after the commit message change. :)

Sorry, you changed the PR title but not the commit itself. Could you please git commit --amend and update the commit message too?

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.

None yet

3 participants