object CantonRequireTypes
Encapsulates those classes and their utility methods which enforce a given invariant via the use of require.
- Alphabetic
- By Inheritance
- CantonRequireTypes
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait AbstractLengthLimitedString extends NoCopy
This trait wraps a String that is limited to a certain maximum length.
This trait wraps a String that is limited to a certain maximum length. The canonical use case is ensuring that we don't write too long strings into the database.
You should normally implement LengthLimitedString or use its subclasses, for strings to be stored in standard string columns.
As this class implements fewer checks, this also serves as the basis for longer strings such as CLOBs.
- final case class InstanceName extends NoCopy with PrettyPrinting with Product with Serializable
- sealed trait LengthLimitedString extends AbstractLengthLimitedString
This trait wraps a String that is limited to a certain maximum length.
This trait wraps a String that is limited to a certain maximum length. Classes implementing this trait expose
create
andtryCreate
methods to safely (and non-safely) construct such a String.The canonical use case for LengthLimitedStrings is ensuring that we don't write too long strings into the database: Oracle has a length-limit of 1000 Unicode characters for the ordinary String type
NVARCHAR2
and we are trying to avoid the use of CLOB (as it has pitfalls regarding implicits). This validation generally occurs on the server side and not on the client side. Concretely, this means that the Admin API and Ledger API gRPC services is the point where we validate that the received Protobuf Strings are not too long (and convert them into LengthLimitedStrings). On the client side, e.g. at the console, we generally take normal String types. The console commandset_display_name
and service com.digitalasset.canton.participant.admin.grpc.GrpcPartyNameManagementService validatingrequest.displayName
illustrate this.As a rule of thumb: whenever you want to create a column that uses a NVARCHAR2 in Oracle, the value you write to it should use a LengthLimitedString.
Some more background on the Oracle issues: NVARCHAR and NVARCHAR2 have both by default a 4000 byte limit, but unicode uses 4-bytes per character (and nvarchar2 uses unicode) Therefore, NVARCHAR has a limit of 4000 and NVARCHAR2 has a limit of 1000 characters If need be, we can extend this to 32 KB by setting the Oracle database string size to 'extended mode' (ALTER SYSTEM SET MAX_STRING_SIZE=EXTENDED)
For longer strings, directly inherit from AbstractLengthLimitedString.
- trait LengthLimitedStringCompanion[A <: AbstractLengthLimitedString] extends AnyRef
Trait that implements method commonly needed in the companion object of an AbstractLengthLimitedString
- final case class LengthLimitedStringVar(str: String, maxLength: Int)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
- trait LengthLimitedStringWrapper extends AnyRef
Trait for case classes that are a wrapper around a LengthLimitedString.
Trait for case classes that are a wrapper around a LengthLimitedString.
- See also
com.digitalasset.canton.crypto.CertificateId for an example
- trait LengthLimitedStringWrapperCompanion[A <: LengthLimitedString, Wrapper <: LengthLimitedStringWrapper] extends AnyRef
Trait that implements utility methods to avoid boilerplate in the companion object of a case class that wraps a LengthLimitedString type using LengthLimitedStringWrapper.
Trait that implements utility methods to avoid boilerplate in the companion object of a case class that wraps a LengthLimitedString type using LengthLimitedStringWrapper.
- See also
com.digitalasset.canton.crypto.CertificateId for an example
- final case class NonEmptyString(str: String) extends NoCopy with Product with Serializable
- final case class String1(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
- final case class String100(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
- final case class String185(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Limit used by com.digitalasset.canton.topology.Identifier.
Limit used by com.digitalasset.canton.topology.Identifier.
- See also
com.digitalasset.canton.topology.Identifier for documentation on its origin
- final case class String2066(str: String)(name: Option[String] = None) extends AbstractLengthLimitedString with Product with Serializable
Length limitation for an com.digitalasset.canton.protocol.LfTemplateId.
Length limitation for an com.digitalasset.canton.protocol.LfTemplateId. A com.digitalasset.canton.protocol.LfTemplateId consists of - The module name (com.daml.lf.data.Ref.DottedName) - The template name (com.daml.lf.data.Ref.DottedName) - The package ID - Two separating dots Each com.daml.lf.data.Ref.DottedName can have 1000 chars (com.daml.lf.data.Ref.DottedName.maxLength). So a com.digitalasset.canton.protocol.LfTemplateId serializes to 1000 + 1000 + 64 + 2 = 2066 chars.
2066 is beyond the string size for Oracle's
NVARCHAR2
column type unlessmax_string_size
is set toextended
. Such strings may therefore be written intoVARCHAR2
columns using an encoding that does not exceed the 4000 bytes limit. UTF8 is such an encoding for ASCII-only strings, but we do not yet test thatstr
really contains only ASCII characters. - final case class String255(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Default LengthLimitedString that should be used when in doubt.
Default LengthLimitedString that should be used when in doubt. 255 was chosen as it is also the limit used in the upstream code for, e.g., LedgerStrings in the upstream code
- name
optionally set it to improve the error message. It is given as an extra argument, so the automatically generated
equals
-method doesn't use it for comparison
- final case class String256M(str: String)(name: Option[String] = None) extends AbstractLengthLimitedString with Product with Serializable
Length limitation of a
TEXT
or unboundedVARCHAR
field in postgres orCLOB
in Oracle.Length limitation of a
TEXT
or unboundedVARCHAR
field in postgres orCLOB
in Oracle. - PostgresTEXT
orVARCHAR
support up to 1GB storage. That is at least2 28
UTF8 characterscharacters in UTF8 encoding as each character needs at most 4 bytes. - Oracle
CLOBsupports up to 4GB storage, i.e., at least
2 30TEXT
/VARCHAR
/CLOB
are only used for the following values (none are indices): - daml_packages.source_description - service_agreements.agreement_text - topology_transactions.ignore_reason - sequencer_events.error_message - final case class String3(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Limit used for enum names.
- final case class String300(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Longest limited-length strings that have been needed so far.
Longest limited-length strings that have been needed so far. Typical use case: when a 255-length identifier is combined with other short suffixes or prefixes to further specialize them.
- See also
com.digitalasset.canton.store.db.SequencerClientDiscriminator
com.digitalasset.canton.crypto.KeyName
- final case class String36(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Limit used by a UUID.
- final case class String68(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Limit used by a hash (SHA256 in particular) in a com.digitalasset.canton.topology.UniqueIdentifier.
Limit used by a hash (SHA256 in particular) in a com.digitalasset.canton.topology.UniqueIdentifier.
- See also
com.digitalasset.canton.topology.UniqueIdentifier for documentation on its origin
- final case class String73(str: String)(name: Option[String] = None) extends LengthLimitedString with Product with Serializable
Limit used by a com.digitalasset.canton.sequencing.protocol.MessageId.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object InstanceName extends Serializable
- object LengthLimitedString
- object LengthLimitedStringVar extends Serializable
- object NonEmptyString extends Serializable
- object String1 extends LengthLimitedStringCompanion[String1] with Serializable
- object String100 extends LengthLimitedStringCompanion[String100] with Serializable
- object String185 extends LengthLimitedStringCompanion[String185] with Serializable
- object String2066 extends LengthLimitedStringCompanion[String2066] with Serializable
- object String255 extends LengthLimitedStringCompanion[String255] with Serializable
- object String256M extends LengthLimitedStringCompanion[String256M] with Serializable
- object String3 extends LengthLimitedStringCompanion[String3] with Serializable
- object String300 extends LengthLimitedStringCompanion[String300] with Serializable
- object String36 extends LengthLimitedStringCompanion[String36] with Serializable
- object String68 extends LengthLimitedStringCompanion[String68] with Serializable
- object String73 extends LengthLimitedStringCompanion[String73] with Serializable