Add VARCHAR

Issue #160 wontfix
Former user created an issue

Originally reported on Google Code with ID 160

I would like to be able to choose 'VARCHAR' as data type and specify a length.

Reported by swenkooij on 2012-11-26 18:04:39

Comments (4)

  1. Christopher Kramer
    Well, the easy answer is: Use another DBMS then ;-)
    
    SQLite does not use this information if you specify it. You can specify it, but it
    will simply be ignored. From http://www.sqlite.org/faq.html#q9 :
    
    SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and
    SQLite will be happy to let you put 500 characters in it. And it will keep all 500
    characters intact - it never truncates.
    
    So I would say it does not make any sense to specify a field VARCHAR(10). This will
    only create the wrong impression that the string cannot be longer.
    
    In fact there usually is a maximum length of one billion for any TEXT or BLOB field
    specified by a preprocessor macro (at compile time!):
    http://www.sqlite.org/limits.html#max_length
    
    To ensure that a string cannot be larger, you can use a CHECK constraint (which will
    raise a constraint violataion if the length is too large - not truncate it!) or use
    a trigger.
    
    So these remarks to help you with SQLite. I don't see anything phpLiteAdmin should
    implement in this regard.
    Only thing I could image would be to implicitely create a trigger checking the length
    if somebody created a VARCHAR of a given length. But users who know SQLite would expect
    that the specified length is weak, which would be wrong then.
    

    Reported by crazy4chrissi on 2012-11-26 19:47:50

  2. Christopher Kramer
    Ah, and if you follow the SQLite logic: Don't consider it a bug - it's a feature!
    You'll never get the problem that data gets truncated.
    
    I really meant my first sentence seriously. If you don't like the way SQLite does things,
    better use a more sophisticated DBMS (postrgeSQL or MySQL (with InnoDB) for example).
    I heard there is a fairly popular web-GUI available for MySQL as well ;-)
    

    Reported by crazy4chrissi on 2012-11-26 20:00:56

  3. Christopher Kramer
    As long as nobody gives a good reason why this makes sense, I'll mark it as "Won't fix."
    

    Reported by crazy4chrissi on 2012-11-28 10:56:18 - Status changed: WontFix

  4. Christopher Kramer
    Issue 165 has been merged into this issue.
    

    Reported by crazy4chrissi on 2013-01-12 19:13:11

  5. Log in to comment