Hi Rainer,

thanks for your answer. I know I could solve this by changing the data type.


I just checked the Postgres Docs at 
https://www.postgresql.org/docs/current/static/datatype-character.html 
<https://www.postgresql.org/docs/current/static/datatype-character.html>

Values of type character are physically padded with spaces to the specified 
width n, and are stored and displayed that way. However, trailing spaces are 
treated as semantically insignificant and disregarded when comparing two values 
of type character. In collations where whitespace is significant, this behavior 
can produce unexpected results; for example SELECT 'a '::CHAR(2) collate "C" < 
E'a\n'::CHAR(2) returns true, even though C locale would consider a space to be 
greater than a newline. Trailing spaces are removed when converting a character 
value to one of the other string types. Note that trailing spaces are 
semantically significant in character varying and text values, and when using 
pattern matching, that is LIKE and regular expressions.


And the Oracle Docs at 
https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1821 
<https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1821>

Oracle Database compares CHAR values using blank-padded comparison semantics.


And the MySQL Docs at 
https://docs.oracle.com/cd/E17952_01/mysql-5.1-en/char.html 
<https://docs.oracle.com/cd/E17952_01/mysql-5.1-en/char.html>

The length of a CHAR column is fixed to the length that you declare when you 
create the table. The length can be any value from 0 to 255. When CHAR values 
are stored, they are right-padded with spaces to the specified length. When 
CHAR values are retrieved, trailing spaces are removed unless the 
PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.


For me thats not like empire-db options resolving behaves.

- jan


> Am 22.03.2018 um 10:29 schrieb Rainer Döbele <[email protected]>:
> 
> It's the same in Oracle if you define it as CHAR.
> I only use CHAR when the value always exactly has the defined length.
> Otherwise you should use VARCHAR.
> In fact, that’s what VARCAHR is for.
> 
> Because this is SQL style behaviour, I would not recommend changing anything 
> in Emprie-db as it may result in unexpected behaviour.
> 
> Regards,
> Rainer
> 
> 
>> from: Jan Glaubitz <[email protected]>
>> to: [email protected]
>> subject: Problem using empire-jsf SelectInputControl with Enum and CHAR
>> 
>> Hi all,
>> 
>> I’m using the empire-jsf SelectInputControl with a column thats defined as
>> CHAR(2). Recently I added a new option that has only one char, I can set the
>> value, but its never rendered in read-only mode.
>> 
>> I figured out that the length of the String in java, which comes from the
>> postgres jdbc driver is always 2. So my new option „B“ is really „B „. This 
>> is
>> really strange, when I do "SELECT COLUMN, LENGTH(COLUMN)“ postgres
>> says its 1.
>> 
>> Can anyone test if that is a jdbc-specific thing and is the same on e. g. 
>> Oracle?
>> 
>> I worked around that problem for now overriding
>> SelectInputControl.formatValue and trimming the value. But maybe there
>> should be a general solution?
>> 
>> - jan

Reply via email to