| 126 | | =head2 Native Primitive Types |
| 127 | | |
| 128 | | These are the simplest data types, from which all others are derived: |
| 129 | | |
| 130 | | =over |
| 131 | | |
| 132 | | =item C<NULL> |
| 133 | | |
| 134 | | This special data type represents situations where a value of an arbitrary |
| 135 | | data type is desired but none is yet known; it sits in place of the absent |
| 136 | | value to indicate that fact. NULL artifacts will always explicitly compare |
| 137 | | as being unequal to each other; since they all represent unknowns, we can |
| 138 | | not logically say any are equal, so they are all treated as distinct. This |
| | 126 | =head2 Native Null Type |
| | 127 | |
| | 128 | SQL::Routine natively supports the special NULL data type, whose value |
| | 129 | domain is by definition mutually exclusive of the domains of all other data |
| | 130 | types; in practice, a NULL is distinct from all possible values that the |
| | 131 | other SQL::Routine native primitive types can have. But some built-in |
| | 132 | complex types and user customized types could be defined where their |
| | 133 | domains are a super-set of NULL; those latter types are described as |
| | 134 | "nullable", while types whose domains are not a super-set of NULL are |
| | 135 | described as "not nullable". |
| | 136 | |
| | 137 | The NULL data type represents situations where a value of an arbitrary data |
| | 138 | type is desired but none is yet known; it sits in place of the absent value |
| | 139 | to indicate that fact. NULL artifacts will always explicitly compare as |
| | 140 | being unequal to each other; since they all represent unknowns, we can not |
| | 141 | logically say any are equal, so they are all treated as distinct. This |
| | 145 | SQL::Routine does not allow you to declare "domain" Nodes that are simply |
| | 146 | of or based on the data type NULL; rather, to use NULL you must declare |
| | 147 | "domain" Nodes that are either based on a not-nullable data type unioned |
| | 148 | with the NULL type, or are based on a nullable data type. The "domain" |
| | 149 | Node type provides a short-hand to indicate the union of its base type with |
| | 150 | NULL, in the form of the boolean "is_nullable" attribute; if the attribute |
| | 151 | is undefined, then the nullability status of the base data type is |
| | 152 | inherited; if it is defined, then it overrides the parent's status. |
| | 153 | |
| | 154 | All not-nullable built-in data types default to their concept of empty or |
| | 155 | nothingness, such as zero or the empty string. All nullable built-in |
| | 156 | types, and all not-nullable built-in types that you customize with a true |
| | 157 | is_nullable, will default to NULL. In either case, you can define an |
| | 158 | explicit default value for your custom data type, which will override those |
| | 159 | behaviours; details are given further below. |
| | 160 | |
| | 161 | =head2 Native Primitive Types |
| | 162 | |
| | 163 | These are the simplest data types, from which all others are derived: |
| | 164 | |
| | 165 | =over |
| | 166 | |
| 149 | | This data type is a rational integer of unlimited (but not infinite) |
| 150 | | precision. It is a sub-domain of RATIONAL and will natively cast to (and |
| 151 | | sometimes from) that. This data type is not nullable and defaults to zero. |
| | 174 | This not-nullable data type is a rational integer of unlimited (but not |
| | 175 | infinite) precision. Its concept of nothingness is zero. It is |
| | 176 | conceptually a full sub-domain of RATIONAL, such that all INTEGER values |
| | 177 | have one-on-one RATIONAL equivalents, but for widely pervasive matters of |
| | 178 | efficiency, SQL::Routine will treat the two types as exclusive, so you need |
| | 179 | to do explicit conversions between them. |
| 167 | | This data type is a bit string of unlimited (but not infinite) |
| 168 | | length. This data type is not nullable and defaults to the empty string. |
| 169 | | |
| 170 | | =item C<SCALAR> |
| 171 | | |
| 172 | | This data type is a union of the domains of the BOOLEAN, RATIONAL (includes |
| 173 | | INTEGER), CHAR_STR, and BIT_STR data types. It is a weakly typed scalar |
| 174 | | like Perl's default variables, or SQLite's default table columns. This |
| 175 | | data type is not nullable and defaults to the empty string. |
| 176 | | |
| 177 | | =item C<NULL_BOOLEAN> |
| 178 | | |
| 179 | | This data type is a union of the domains of the NULL and BOOLEAN data |
| 180 | | types; it is a nullable logical boolean and defaults to NULL. |
| 181 | | |
| 182 | | =item C<NULL_INTEGER> |
| 183 | | |
| 184 | | This data type is a union of the domains of the NULL and INTEGER data |
| 185 | | types; it is a nullable rational integer and defaults to NULL. |
| 186 | | |
| 187 | | =item C<NULL_RATIONAL> |
| 188 | | |
| 189 | | This data type is a union of the domains of the NULL and RATIONAL data |
| 190 | | types; it is a nullable rational number and defaults to NULL. |
| 191 | | |
| 192 | | =item C<NULL_CHAR_STR> |
| 193 | | |
| 194 | | This data type is a union of the domains of the NULL and CHAR_STR data |
| 195 | | types; it is a nullable character string and defaults to NULL. |
| 196 | | |
| 197 | | =item C<NULL_BIT_STR> |
| 198 | | |
| 199 | | This data type is a union of the domains of the NULL and BIT_STR data |
| 200 | | types; it is a nullable bit string and defaults to NULL. |
| 201 | | |
| 202 | | =item C<NULL_SCALAR> |
| 203 | | |
| 204 | | This data type is a union of the domains of the NULL and SCALAR data |
| 205 | | types; it is a nullable weakly typed scalar and defaults to NULL. |
| | 194 | This not-nullable data type is a bit string of unlimited (but not infinite) |
| | 195 | length. Its concept of nothingness is the empty string. |
| | 198 | |
| | 199 | =head2 Native Scalar Type |
| | 200 | |
| | 201 | SQL::Routine has native support for a special SCALAR data type, which is |
| | 202 | akin to SQLite's weakly typed table columns, or to Perl's weakly typed |
| | 203 | default scalar variables. This not-nullable data type is a union of the |
| | 204 | domains of the BOOLEAN, INTEGER, RATIONAL, CHAR_STR, and BIT_STR |
| | 205 | data types. Its concept of nothingness is the empty string. |