Skip to content

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

Open
revsi wants to merge 1 commit into
nihavi:masterfrom
revsi:patch-1
Open

Set default value for Not Null Column in CRE.sql#3
revsi wants to merge 1 commit into
nihavi:masterfrom
revsi:patch-1

Conversation

@revsi

@revsi revsi commented Sep 15, 2016

Copy link
Copy Markdown

No description provided.

@polybuildr

polybuildr commented Sep 15, 2016

Copy link
Copy Markdown
Collaborator

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

@polybuildr polybuildr left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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

@revsi

revsi commented Sep 15, 2016

Copy link
Copy Markdown
Author

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

@polybuildr polybuildr left a comment

Copy link
Copy Markdown
Collaborator

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.

3 participants