|
| 1 | +# Copyright (c) 2021 The PyBigQuery Authors |
| 2 | +# |
| 3 | +# Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 | +# this software and associated documentation files (the "Software"), to deal in |
| 5 | +# the Software without restriction, including without limitation the rights to |
| 6 | +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 7 | +# the Software, and to permit persons to whom the Software is furnished to do so, |
| 8 | +# subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included in all |
| 11 | +# copies or substantial portions of the Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 15 | +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 16 | +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 17 | +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 | +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 | +""" |
| 20 | +This module is used by the compliance tests to control which tests are run |
| 21 | +
|
| 22 | +based on database capabilities. |
| 23 | +""" |
| 24 | + |
| 25 | +import sqlalchemy.testing.requirements |
| 26 | +import sqlalchemy.testing.exclusions |
| 27 | + |
| 28 | +supported = sqlalchemy.testing.exclusions.open |
| 29 | +unsupported = sqlalchemy.testing.exclusions.closed |
| 30 | + |
| 31 | + |
| 32 | +class Requirements(sqlalchemy.testing.requirements.SuiteRequirements): |
| 33 | + @property |
| 34 | + def index_reflection(self): |
| 35 | + return unsupported() |
| 36 | + |
| 37 | + @property |
| 38 | + def indexes_with_ascdesc(self): |
| 39 | + """target database supports CREATE INDEX with per-column ASC/DESC.""" |
| 40 | + return unsupported() |
| 41 | + |
| 42 | + @property |
| 43 | + def unique_constraint_reflection(self): |
| 44 | + """target dialect supports reflection of unique constraints""" |
| 45 | + return unsupported() |
| 46 | + |
| 47 | + @property |
| 48 | + def autoincrement_insert(self): |
| 49 | + """target platform generates new surrogate integer primary key values |
| 50 | + when insert() is executed, excluding the pk column.""" |
| 51 | + return unsupported() |
| 52 | + |
| 53 | + @property |
| 54 | + def primary_key_constraint_reflection(self): |
| 55 | + return unsupported() |
| 56 | + |
| 57 | + @property |
| 58 | + def foreign_keys(self): |
| 59 | + """Target database must support foreign keys.""" |
| 60 | + |
| 61 | + return unsupported() |
| 62 | + |
| 63 | + @property |
| 64 | + def foreign_key_constraint_reflection(self): |
| 65 | + return unsupported() |
| 66 | + |
| 67 | + @property |
| 68 | + def on_update_cascade(self): |
| 69 | + """target database must support ON UPDATE..CASCADE behavior in |
| 70 | + foreign keys.""" |
| 71 | + |
| 72 | + return unsupported() |
| 73 | + |
| 74 | + @property |
| 75 | + def named_constraints(self): |
| 76 | + """target database must support names for constraints.""" |
| 77 | + |
| 78 | + return unsupported() |
| 79 | + |
| 80 | + @property |
| 81 | + def temp_table_reflection(self): |
| 82 | + return unsupported() |
| 83 | + |
| 84 | + @property |
| 85 | + def temporary_tables(self): |
| 86 | + """target database supports temporary tables""" |
| 87 | + return unsupported() # Temporary tables require use of scripts. |
| 88 | + |
| 89 | + @property |
| 90 | + def duplicate_key_raises_integrity_error(self): |
| 91 | + """target dialect raises IntegrityError when reporting an INSERT |
| 92 | + with a primary key violation. (hint: it should) |
| 93 | +
|
| 94 | + """ |
| 95 | + return unsupported() |
| 96 | + |
| 97 | + @property |
| 98 | + def precision_numerics_many_significant_digits(self): |
| 99 | + """target backend supports values with many digits on both sides, |
| 100 | + such as 319438950232418390.273596, 87673.594069654243 |
| 101 | +
|
| 102 | + """ |
| 103 | + return supported() |
| 104 | + |
| 105 | + @property |
| 106 | + def date_coerces_from_datetime(self): |
| 107 | + """target dialect accepts a datetime object as the target |
| 108 | + of a date column.""" |
| 109 | + |
| 110 | + # BigQuery doesn't allow saving a datetime in a date: |
| 111 | + # `TYPE_DATE`, Invalid date: '2012-10-15T12:57:18' |
| 112 | + |
| 113 | + return unsupported() |
| 114 | + |
| 115 | + @property |
| 116 | + def window_functions(self): |
| 117 | + """Target database must support window functions.""" |
| 118 | + return supported() # There are no tests for this. <shrug> |
| 119 | + |
| 120 | + @property |
| 121 | + def ctes(self): |
| 122 | + """Target database supports CTEs""" |
| 123 | + |
| 124 | + return supported() |
| 125 | + |
| 126 | + @property |
| 127 | + def views(self): |
| 128 | + """Target database must support VIEWs.""" |
| 129 | + |
| 130 | + return supported() |
| 131 | + |
| 132 | + @property |
| 133 | + def schemas(self): |
| 134 | + """Target database must support external schemas, and have one |
| 135 | + named 'test_schema'.""" |
| 136 | + |
| 137 | + return supported() |
| 138 | + |
| 139 | + @property |
| 140 | + def implicit_default_schema(self): |
| 141 | + """target system has a strong concept of 'default' schema that can |
| 142 | + be referred to implicitly. |
| 143 | +
|
| 144 | + basically, PostgreSQL. |
| 145 | +
|
| 146 | + """ |
| 147 | + return supported() |
| 148 | + |
| 149 | + @property |
| 150 | + def comment_reflection(self): |
| 151 | + return supported() # Well, probably not, but we'll try. :) |
| 152 | + |
| 153 | + @property |
| 154 | + def unicode_ddl(self): |
| 155 | + """Target driver must support some degree of non-ascii symbol |
| 156 | + names. |
| 157 | + """ |
| 158 | + return supported() |
| 159 | + |
| 160 | + @property |
| 161 | + def datetime_literals(self): |
| 162 | + """target dialect supports rendering of a date, time, or datetime as a |
| 163 | + literal string, e.g. via the TypeEngine.literal_processor() method. |
| 164 | +
|
| 165 | + """ |
| 166 | + |
| 167 | + return supported() |
| 168 | + |
| 169 | + @property |
| 170 | + def timestamp_microseconds(self): |
| 171 | + """target dialect supports representation of Python |
| 172 | + datetime.datetime() with microsecond objects but only |
| 173 | + if TIMESTAMP is used.""" |
| 174 | + return supported() |
| 175 | + |
| 176 | + @property |
| 177 | + def datetime_historic(self): |
| 178 | + """target dialect supports representation of Python |
| 179 | + datetime.datetime() objects with historic (pre 1970) values.""" |
| 180 | + |
| 181 | + return supported() |
| 182 | + |
| 183 | + @property |
| 184 | + def date_historic(self): |
| 185 | + """target dialect supports representation of Python |
| 186 | + datetime.datetime() objects with historic (pre 1970) values.""" |
| 187 | + |
| 188 | + return supported() |
| 189 | + |
| 190 | + @property |
| 191 | + def precision_numerics_enotation_small(self): |
| 192 | + """target backend supports Decimal() objects using E notation |
| 193 | + to represent very small values.""" |
| 194 | + return supported() |
| 195 | + |
| 196 | + @property |
| 197 | + def precision_numerics_enotation_large(self): |
| 198 | + """target backend supports Decimal() objects using E notation |
| 199 | + to represent very large values.""" |
| 200 | + return supported() |
| 201 | + |
| 202 | + @property |
| 203 | + def update_from(self): |
| 204 | + """Target must support UPDATE..FROM syntax""" |
| 205 | + return supported() |
| 206 | + |
| 207 | + @property |
| 208 | + def order_by_label_with_expression(self): |
| 209 | + """target backend supports ORDER BY a column label within an |
| 210 | + expression. |
| 211 | +
|
| 212 | + Basically this:: |
| 213 | +
|
| 214 | + select data as foo from test order by foo || 'bar' |
| 215 | +
|
| 216 | + Lots of databases including PostgreSQL don't support this, |
| 217 | + so this is off by default. |
| 218 | +
|
| 219 | + """ |
| 220 | + return supported() |
0 commit comments