Commit e5df083d authored by Kevin Morris's avatar Kevin Morris
Browse files

use String(max_len) for DECIMAL types with sqlite



This solves an issue where DECIMAL is not native
to sqlite by using a string to store values and
converting them to float in user code.
Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent a65a6060
......@@ -107,7 +107,10 @@ PackageBases = Table(
Column('ID', INTEGER(unsigned=True), primary_key=True),
Column('Name', String(255), nullable=False, unique=True),
Column('NumVotes', INTEGER(unsigned=True), nullable=False, server_default=text("0")),
Column('Popularity', DECIMAL(10, 6, unsigned=True), nullable=False, server_default=text("0")),
Column('Popularity',
DECIMAL(10, 6, unsigned=True)
if db_backend == "mysql" else String(16), # Stubbed out to test.
nullable=False, server_default=text("0")),
Column('OutOfDateTS', BIGINT(unsigned=True)),
Column('FlaggerComment', Text, nullable=False),
Column('SubmittedTS', BIGINT(unsigned=True), nullable=False),
......@@ -383,7 +386,10 @@ TU_VoteInfo = Table(
Column('User', String(32), nullable=False),
Column('Submitted', BIGINT(unsigned=True), nullable=False),
Column('End', BIGINT(unsigned=True), nullable=False),
Column('Quorum', DECIMAL(2, 2, unsigned=True), nullable=False),
Column('Quorum',
DECIMAL(2, 2, unsigned=True)
if db_backend == "mysql" else String(4),
nullable=False),
Column('SubmitterID', ForeignKey('Users.ID', ondelete='CASCADE'), nullable=False),
Column('Yes', TINYINT(3, unsigned=True), nullable=False, server_default=text("'0'")),
Column('No', TINYINT(3, unsigned=True), nullable=False, server_default=text("'0'")),
......
......@@ -67,8 +67,11 @@ if (has_credential(CRED_TU_ADD_VOTE)) {
}
}
if (!empty($_POST['addVote']) && empty($error)) {
add_tu_proposal($_POST['agenda'], $_POST['user'], $len, $quorum, $uid);
if (!empty($_POST['addVote']) && empty($error)) {
// Convert $quorum to a String of maximum length "12.34" (5).
$quorum_str = substr(strval($quorum), min(5, strlen($quorum));
add_tu_proposal($_POST['agenda'], $_POST['user'],
$len, $quorum_str, $uid);
print "<p class=\"pkgoutput\">" . __("New proposal submitted.") . "</p>\n";
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment