What is maximum length of a long string field in type system

#1

If I have a type with a long string field,

entity type HelloWorldPage {
   htmlContent: long string
}

What is maximum length of htmlContent? Could I create a new HelloWorldPage entry with htmlContent containing 10000 characters?

0 Likes

#2

from c3ShowType("String")

Unicode character string declared as string. The actual character encoding depends on the language binding, but is typically UTF-8 (UTF-16 in Java).
Strings stored in the SQL databases can come in several flavors:
*string is stored in a varchar column of at least 512 bytes
*long string is stored in a varchar or text of least 2000 bytes
*clob is stored as text of arbitrary length
Strings stored in NoSQL databases are always arbitrary length.
Strings should not be used to store binary data because not all possible binary values are legal strings in most encodings. Use binary instead.

0 Likes

#3

I’m updating the documentation as follows:

string is stored in a varchar or text column of 512 characters
long string is stored in a varchar or text of 4000 characters
clob is stored as text of arbitrary length

0 Likes

#4

Is there a way to specify the maximum length of a field using a db annotation?

0 Likes

#5

Yes, see the length field on the Db annotation: c3ShowType(C3.annotation.Db)

length: int
Maximum length for a string field. If -1, no maximum length is enforced.

Though I believe the length specified has to be less than the length limit of the data type (i.e. string, long string)

An example of this is Persistable.id:

@db(length=64)
id: string
0 Likes