| 1 |
CREATE SCHEMA xtest; |
| 2 |
CREATE TABLE xtest.table (id INT DEFAULT 0, name VARCHAR(40) DEFAULT 'Bob', value FLOAT DEFAULT 3.14 ); |
| 3 |
CREATE TABLE xtest.fault (value INT NOT NULL); |
| 4 |
send Mysqlx.Crud.Insert { |
| 5 |
collection { |
| 6 |
name: "table" |
| 7 |
schema: "xtest" |
| 8 |
} |
| 9 |
data_model: TABLE |
| 10 |
projection { |
| 11 |
name: "id" |
| 12 |
} |
| 13 |
projection { |
| 14 |
name: "name" |
| 15 |
} |
| 16 |
projection { |
| 17 |
name: "value" |
| 18 |
} |
| 19 |
row { |
| 20 |
field { |
| 21 |
type: LITERAL |
| 22 |
literal { |
| 23 |
type: V_SINT |
| 24 |
v_signed_int: 1 |
| 25 |
} |
| 26 |
} |
| 27 |
field { |
| 28 |
type: LITERAL |
| 29 |
literal { |
| 30 |
type: V_STRING |
| 31 |
v_string { |
| 32 |
value: "Ann" |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
field { |
| 37 |
type: LITERAL |
| 38 |
literal { |
| 39 |
type: V_FLOAT |
| 40 |
v_float: 10.1 |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
row { |
| 45 |
field { |
| 46 |
type: OPERATOR |
| 47 |
operator { |
| 48 |
name: "default" |
| 49 |
} |
| 50 |
} |
| 51 |
field { |
| 52 |
type: LITERAL |
| 53 |
literal { |
| 54 |
type: V_STRING |
| 55 |
v_string { |
| 56 |
value: "Cezar" |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
field { |
| 61 |
type: LITERAL |
| 62 |
literal { |
| 63 |
type: V_FLOAT |
| 64 |
v_float: 10.2 |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
row { |
| 69 |
field { |
| 70 |
type: LITERAL |
| 71 |
literal { |
| 72 |
type: V_SINT |
| 73 |
v_signed_int: 2 |
| 74 |
} |
| 75 |
} |
| 76 |
field { |
| 77 |
type: OPERATOR |
| 78 |
operator { |
| 79 |
name: "default" |
| 80 |
} |
| 81 |
} |
| 82 |
field { |
| 83 |
type: LITERAL |
| 84 |
literal { |
| 85 |
type: V_FLOAT |
| 86 |
v_float: 10.3 |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
row { |
| 91 |
field { |
| 92 |
type: LITERAL |
| 93 |
literal { |
| 94 |
type: V_SINT |
| 95 |
v_signed_int: 3 |
| 96 |
} |
| 97 |
} |
| 98 |
field { |
| 99 |
type: LITERAL |
| 100 |
literal { |
| 101 |
type: V_STRING |
| 102 |
v_string { |
| 103 |
value: "Don" |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
field { |
| 108 |
type: OPERATOR |
| 109 |
operator { |
| 110 |
name: "default" |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
row { |
| 115 |
field { |
| 116 |
type: OPERATOR |
| 117 |
operator { |
| 118 |
name: "default" |
| 119 |
} |
| 120 |
} |
| 121 |
field { |
| 122 |
type: OPERATOR |
| 123 |
operator { |
| 124 |
name: "default" |
| 125 |
} |
| 126 |
} |
| 127 |
field { |
| 128 |
type: OPERATOR |
| 129 |
operator { |
| 130 |
name: "default" |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
5 rows affected |
| 138 |
Records: 5 Duplicates: 0 Warnings: 0 |
| 139 |
send Mysqlx.Crud.Insert { |
| 140 |
collection { |
| 141 |
name: "fault" |
| 142 |
schema: "xtest" |
| 143 |
} |
| 144 |
data_model: TABLE |
| 145 |
projection { |
| 146 |
name: "value" |
| 147 |
} |
| 148 |
row { |
| 149 |
field { |
| 150 |
type: OPERATOR |
| 151 |
operator { |
| 152 |
name: "default" |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
Got expected error: |
| 159 |
Mysqlx.Error { |
| 160 |
severity: ERROR |
| 161 |
code: 1364 |
| 162 |
msg: "Field \'value\' doesn\'t have a default value" |
| 163 |
sql_state: "HY000" |
| 164 |
} |
| 165 |
|
| 166 |
send Mysqlx.Crud.Insert { |
| 167 |
collection { |
| 168 |
name: "fault" |
| 169 |
schema: "xtest" |
| 170 |
} |
| 171 |
data_model: TABLE |
| 172 |
projection { |
| 173 |
name: "value" |
| 174 |
} |
| 175 |
row { |
| 176 |
field { |
| 177 |
type: OPERATOR |
| 178 |
operator { |
| 179 |
name: "default" |
| 180 |
param { |
| 181 |
type: LITERAL |
| 182 |
literal { |
| 183 |
type: V_SINT |
| 184 |
v_signed_int: 3 |
| 185 |
} |
| 186 |
} |
| 187 |
} |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
Got expected error: |
| 193 |
Mysqlx.Error { |
| 194 |
severity: ERROR |
| 195 |
code: 5151 |
| 196 |
msg: "Nullary operator require no operands in expression" |
| 197 |
sql_state: "HY000" |
| 198 |
} |
| 199 |
|
| 200 |
Mysqlx.Ok { |
| 201 |
msg: "bye!" |
| 202 |
} |
| 203 |
ok |
| 204 |
SELECT * FROM xtest.table; |
| 205 |
id name value |
| 206 |
1 Ann 10.1 |
| 207 |
0 Cezar 10.2 |
| 208 |
2 Bob 10.3 |
| 209 |
3 Don 3.14 |
| 210 |
0 Bob 3.14 |
| 211 |
SELECT * FROM xtest.fault; |
| 212 |
value |