def test__format_operation_w_sequence(self): from google.cloud.bigquery.dbapi import cursor formatted_operation, _ = cursor._format_operation( "SELECT %s, %s;", ("hello", "world") ) self.assertEqual(formatted_operation, "SELECT ?, ?;")
def test__format_operation_w_sequence(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( "SELECT %s, %s;", ("hello", "world") ) self.assertEqual(formatted_operation, "SELECT ?, ?;")
def test__format_operation_w_redundant_dict_key(self): from google.cloud.bigquery.dbapi import cursor formatted_operation, _ = cursor._format_operation( "SELECT %(somevalue)s;", {"somevalue": "foo", "value-not-used": "bar"} ) self.assertEqual(formatted_operation, "SELECT @`somevalue`;")
def test__format_operation_w_dict(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( 'SELECT %(somevalue)s, %(a `weird` one)s;', { 'somevalue': 'hi', 'a `weird` one': 'world', }) self.assertEqual(formatted_operation, 'SELECT @`somevalue`, @`a \\`weird\\` one`;')
def test__format_operation_w_dict(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( "SELECT %(somevalue)s, %(a `weird` one)s;", {"somevalue": "hi", "a `weird` one": "world"}, ) self.assertEqual( formatted_operation, "SELECT @`somevalue`, @`a \\`weird\\` one`;" )
def test__format_operation_w_dict(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( 'SELECT %(somevalue)s, %(a `weird` one)s;', { 'somevalue': 'hi', 'a `weird` one': 'world', }) self.assertEqual( formatted_operation, 'SELECT @`somevalue`, @`a \\`weird\\` one`;')
def test__format_operation_w_dict(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( "SELECT %(somevalue)s, %(a `weird` one)s;", {"somevalue": "hi", "a `weird` one": "world"}, ) self.assertEqual( formatted_operation, "SELECT @`somevalue`, @`a \\`weird\\` one`;" )
def test__format_operation_w_dict(self): from google.cloud.bigquery.dbapi import cursor parameter_types = {} formatted_operation, parameter_types = cursor._format_operation( "SELECT %(somevalue)s, %(a `weird` one:STRING)s;", {"somevalue": "hi", "a `weird` one": "world"}, ) self.assertEqual( formatted_operation, "SELECT @`somevalue`, @`a \\`weird\\` one`;" ) self.assertEqual(parameter_types, {"a `weird` one": "STRING"})
def test__format_operation_wo_params_double_percents(self): from google.cloud.bigquery.dbapi import cursor formatted_operation, _ = cursor._format_operation("SELECT '%%'", {}) self.assertEqual(formatted_operation, "SELECT '%'")
def test__format_operation_w_empty_dict(self): from google.cloud.bigquery.dbapi import cursor formatted_operation, _ = cursor._format_operation("SELECT '%f'", {}) self.assertEqual(formatted_operation, "SELECT '%f'")
def test__format_operation_w_sequence(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation('SELECT %s, %s;', ('hello', 'world')) self.assertEqual(formatted_operation, 'SELECT ?, ?;')
def test__format_operation_w_sequence(self): from google.cloud.bigquery.dbapi import cursor formatted_operation = cursor._format_operation( 'SELECT %s, %s;', ('hello', 'world')) self.assertEqual(formatted_operation, 'SELECT ?, ?;')