Default value for primary keys incorrect

Issue #149 resolved
Former user created an issue

Originally reported on Google Code with ID 149

What steps will reproduce the problem?

For the primary key in a table, even though Not Null = yes, the Default Value is shown
as NULL. Rather let it show as "None" (in Italics), as is done in phpmyadmin for MySQL.


What version of the product are you using? On what operating system? 
phpLiteAdmin v1.9.3; Windows XP SP3

Which
Database Extension (PDO/SQLiteDatabase/SQLiteDatabase3 - see Database
structure-tab in phpLiteAdmin)?
SQLite version: 2.8.17
SQLite extension: SQLiteDatabase

Reported by jgjooste on 2012-11-21 16:01:44

Comments (12)

  1. Christopher Kramer
    Hmm.. I first though I could not reproduce this as the default value column was simply
    empty for me. But the following creates this problem:
    CREATE TABLE 'test_149' ('null' INTEGER DEFAULT NULL, 'notnull' INTEGER NOT NULL DEFAULT
    NULL)
    
    Okay, but does this make sense? In my opinion SQLite should not even allow this!
    Well, it does. But what should phpLiteAdmin do now?
    It does this:
    PRAGMA TABLE_INFO(test_149_2)
    And SQLite says "the default value is NULL. So it IS null. I mean, it was specified
    this way and SQLite keeps this. Why should phpLiteAdmin say otherwise?
    
    I consider this a really rare case.
    Or do you get the same result for tables that are "normally" specified? Please provide
    us with the CREATE TABLE statement then. Thanks.
    

    Reported by crazy4chrissi on 2012-11-21 16:53:23

  2. Christopher Kramer
    Ah sorry. I did not notice you were talking about primary keys. But this statement does
    not create a problem here:
    CREATE TABLE 'test_149_3' ('primary' INTEGER PRIMARY KEY NOT NULL)
    This one does:
    CREATE TABLE 'test_149_4' ('primary' INTEGER PRIMARY KEY NOT NULL DEFAULT NULL)
    But this again doesn't make much sense.
    

    Reported by crazy4chrissi on 2012-11-21 17:32:18

  3. Christopher Kramer
    This issue was closed by revision r304.
    

    Reported by crazy4chrissi on 2012-11-21 18:52:29 - Status changed: Fixed

  4. Christopher Kramer
    I was now able to reproduce the real issue in 1.9.4 (not 1.9.3).
    I think we introduced the problem lately.
    I just fixed it in SVN.
    

    Reported by crazy4chrissi on 2012-11-21 18:52:57

  5. Christopher Kramer
    P.S.: Thanks for reporting this. Please confirm the fix.
    

    Reported by crazy4chrissi on 2012-11-21 18:53:36

  6. Former user Account Deleted
    Thanks, looks like it is working now. But why not just show the default value of the
    primary key as "None", as is done in phpmyadmin for MySQL?
    

    Reported by jgjooste on 2012-11-27 10:43:02

  7. Christopher Kramer
    Hmm... well, I'd say it's a matter of taste.
    But I guess using NONE (without quotes, so it can be distinguished from the string
    'NONE'), maybe in italics to make clear it is not a normal value, might be a good idea.
    Because with an empty cell, people might assume an empty string is the default or null
    is the default. We should make all these cases unambiguously understandable.
    

    Reported by crazy4chrissi on 2012-11-27 13:39:03 - Status changed: Accepted

  8. Former user Account Deleted
    My vote goes for "None" (without quotes, and in Italics; and not "NONE").
    

    Reported by jgjooste on 2012-11-27 14:00:00

  9. Christopher Kramer
    Okay. Well, I thought to use uppercase like for NULL, but for NULL this is pretty standard.
    Maybe "None" looks a bit more friendly ;-)
    

    Reported by crazy4chrissi on 2012-11-27 14:01:55

  10. Christopher Kramer
    This issue was closed by revision r434.
    

    Reported by crazy4chrissi on 2013-12-25 16:04:59 - Status changed: Fixed

  11. Log in to comment