Unable to automatically insert auto_increment values
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
chive |
Fix Released
|
Medium
|
David Roth |
Bug Description
If you create a table with an primary column that uses auto_increment values, you aren't able to use that feature while inserting.
Coming from phpMyAdmin I'm used to just leave the auto_increment column empty while entering the data to insert. This results in a error, which tells adding the line failed using the following query:
INSERT INTO `table` (`table_id`, `table_value`) VALUES
('', 'example');
Instead of trying to insert an empty string for the auto_increment column `table_id` there should be NULL in the query, which works fine.
Inserting NULL in the form before inserting, chive uses the following query:
INSERT INTO `table` (`table_id`, `table_value`) VALUES
('NULL', 'example');
This obviously failes again, for using NULL as a string.
Related branches
Changed in chive: | |
assignee: | nobody → David Roth (davrot) |
importance: | Undecided → Medium |
milestone: | none → 1.0.2 |
status: | New → Triaged |
Changed in chive: | |
milestone: | 1.0.2 → 1.0.3 |
Changed in chive: | |
status: | Triaged → In Progress |
Changed in chive: | |
status: | Fix Committed → Fix Released |
Hi there,
I don`t really understand the problem.
I tested the following table:
DROP TABLE IF EXISTS `mazzo`;
CREATE TABLE IF NOT EXISTS `mazzo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idgiocatore` int(11) NOT NULL,
`idcarta` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
I can no execute the following queries:
INSERT INTO `mazzo` (`id`, `idgiocatore`, `idcarta`) VALUES
('', '', '');
INSERT INTO `mazzo` (`id`, `idgiocatore`, `idcarta`) VALUES
(null, '', '');
INSERT INTO `mazzo` (`idgiocatore`, `idcarta`) VALUES
('', '');
In all of these cases I get a new row with a new auto_increment value, so everything is ok?