nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kayak/pypika
Pull request #215 (2019-02-06 02:06:18)

Add support for int refference to selected field on group by
Addresses #214 .


Patch:
diff --git a/pypika/queries.py b/pypika/queries.py
index 9e7ca45..98efc49 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -550,6 +550,8 @@ class QueryBuilder(Selectable, Term):
         for term in terms:
             if isinstance(term, str):
                 term = Field(term, table=self._from[0])
+            elif isinstance(term, int):
+                term = Field(str(term), table=self._from[0]).wrap_constant(term)
 
             self._validate_term(term)
             self._groupbys.append(term)


Test patch:
diff --git a/pypika/tests/test_selects.py b/pypika/tests/test_selects.py
index ed747c1..6b97500 100644
--- a/pypika/tests/test_selects.py
+++ b/pypika/tests/test_selects.py
@@ -376,6 +376,11 @@ class GroupByTests(unittest.TestCase):
 
         self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q))
 
+    def test_groupby__int(self):
+        q = Query.from_('abc').groupby(1).select('foo', fn.Count('*').distinct())
+
+        self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q))
+
     def test_groupby__alias(self):
         bar = self.t.bar.as_('bar01')
         q = Query.from_(self.t) \
Repository: kayak/pypika
Pull request #219 (2019-02-08 14:27:00)

Use alias_sql function to generate SQL string

coveralls: 
[![Coverage Status](https://coveralls.io/builds/21532466/badge)](https://coveralls.io/builds/21532466)

Coverage remained the same at 98.236% when pulling **8cd79b3afaaa9cab25de2f07254af161d3a1f465 on vladaspasic:master** into **359289e8918f8acc8a8472453c6e38d385750de3 on kayak:master**.


Patch:
diff --git a/pypika/terms.py b/pypika/terms.py
index f47d57b..30b7109 100644
--- a/pypika/terms.py
+++ b/pypika/terms.py
@@ -435,8 +435,11 @@ class Bracket(Tuple):
         super(Bracket, self).__init__(term)
 
     def get_sql(self, **kwargs):
-        sql = super(Bracket, self).get_sql(**kwargs)
-        return '{sql} {alias}'.format(sql=sql, alias=self.alias) if self.alias else sql
+        return alias_sql(
+            sql=super(Bracket, self).get_sql(**kwargs),
+            alias=self.alias,
+            quote_char=kwargs.get('quote_char', None),
+        )
 
 
 class BasicCriterion(Criterion):


Test patch:
diff --git a/pypika/tests/test_tuples.py b/pypika/tests/test_tuples.py
index ed5b717..f2ede6c 100644
--- a/pypika/tests/test_tuples.py
+++ b/pypika/tests/test_tuples.py
@@ -86,4 +86,4 @@ class BracketTests(unittest.TestCase):
             .from_(self.table_abc) \
             .select(Bracket(self.table_abc.foo / 2).as_('alias'))
 
-        self.assertEqual('SELECT ("foo"/2) alias FROM "abc"', str(q))
+        self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q))
Repository: kayak/pypika
Pull request #252 (2019-05-20 17:35:37)

Fix NULLIF syntax so it generates functional SQL
The correct syntax for NULLIF is:
```
SELECT NULLIF("foo",0) FROM "abc"
```
Instead of:
```
SELECT NULLIF("foo"=0) FROM "abc"
```


Patch:
diff --git a/pypika/functions.py b/pypika/functions.py
index 849b8e5..6ab9f59 100644
--- a/pypika/functions.py
+++ b/pypika/functions.py
@@ -157,8 +157,8 @@ class Ascii(Function):
 
 
 class NullIf(Function):
-    def __init__(self, criterion, alias=None):
-        super(NullIf, self).__init__('NULLIF', criterion, alias=alias)
+    def __init__(self, term, condition, **kwargs):
+        super(NullIf, self).__init__('NULLIF', term, condition, **kwargs)
 
 
 class Bin(Function):


Test patch:
diff --git a/pypika/tests/test_functions.py b/pypika/tests/test_functions.py
index cee80f4..e80d4b5 100644
--- a/pypika/tests/test_functions.py
+++ b/pypika/tests/test_functions.py
@@ -607,9 +607,9 @@ class NullFunctionsTests(unittest.TestCase):
         self.assertEqual('SELECT COALESCE(\"foo\",0) FROM \"abc\"', str(q))
 
     def test_nullif(self):
-        q = Q.from_('abc').select(fn.NullIf(F('foo') == 0))
+        q = Q.from_('abc').select(fn.NullIf(F('foo'), 0))
 
-        self.assertEqual('SELECT NULLIF(\"foo\"=0) FROM \"abc\"', str(q))
+        self.assertEqual('SELECT NULLIF(\"foo\",0) FROM \"abc\"', str(q))
 
     def test_nvl(self):
         q = Q.from_('abc').select(fn.NVL(F('foo'), 0))
Repository: kayak/pypika
Pull request #257 (2019-06-08 12:19:17)

Support instantiate many tables with alias
In order to be faster and easier to instantiate many tables with an alias, `make_tables` shortcut function has been modified to support tuples with two elements which the first represents the `_table_name` and the second is the `alias`.


Patch:
diff --git a/pypika/queries.py b/pypika/queries.py
index 2242ac5..ab63847 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -150,7 +150,19 @@ class Table(Selectable):
 
 
 def make_tables(*names, **kwargs):
-    return [Table(name, schema=kwargs.get('schema')) for name in names]
+    """
+        Shortcut to create many tables. If `names` param is a tuple, the first
+        position will refer to the `_table_name` while the second will be its `alias`.
+        Any other data structure will be treated as a whole as the `_table_name`
+    """
+    tables = []
+    for name in names:
+        if isinstance(name, tuple) and len(name) == 2:
+            t = Table(name=name[0], alias=name[1], schema=kwargs.get('schema'))
+        else:
+            t = Table(name=name, schema=kwargs.get('schema'))
+        tables.append(t)
+    return tables
 
 
 class Query(object):


Test patch:
diff --git a/pypika/tests/test_tables.py b/pypika/tests/test_tables.py
index c23f2a5..05cf5f5 100644
--- a/pypika/tests/test_tables.py
+++ b/pypika/tests/test_tables.py
@@ -3,6 +3,7 @@ import unittest
 from pypika import (
     Schema,
     Table,
+    Tables
 )
 
 __author__ = "Timothy Heys"
@@ -56,3 +57,24 @@ class TableEqualityTests(unittest.TestCase):
         t2 = Table("q", schema='a')
 
         self.assertNotEqual(t1, t2)
+
+    def test_many_tables_with_alias(self):
+        tables_data = [('table1', 't1'), ('table2', 't2'), ('table3', 't3')]
+        tables = Tables(*tables_data)
+        for el in tables:
+            self.assertIsNotNone(el.alias)
+
+    def test_many_tables_without_alias(self):
+        tables_data = ['table1', 'table2', 'table3']
+        tables = Tables(*tables_data)
+        for el in tables:
+            self.assertIsNone(el.alias)
+
+    def test_many_tables_with_or_not_alias(self):
+        tables_data = [('table1', 't1'), ('table2'), 'table3']
+        tables = Tables(*tables_data)
+        for i in range(len(tables)):
+            if isinstance(tables_data[i], tuple):
+                self.assertIsNotNone(tables[i].alias)
+            else:
+                self.assertIsNone(tables[i].alias)
Repository: kayak/pypika
Pull request #262 (2019-06-21 19:31:16)

Add support for Oracle's TO_DATE function.
Add support for Oracle's TO_DATE function.


Patch:
diff --git a/pypika/functions.py b/pypika/functions.py
index 6ab9f59..52cf3c4 100644
--- a/pypika/functions.py
+++ b/pypika/functions.py
@@ -140,6 +140,11 @@ class DateAdd(Function):
         super(DateAdd, self).__init__('DATE_ADD', date_part, interval, term, alias=alias)
 
 
+class ToDate(Function):
+    def __init__(self, value, format_mask, alias=None):
+        super(ToDate, self).__init__('TO_DATE', value, format_mask, alias=alias)
+
+
 class Timestamp(Function):
     def __init__(self, term, alias=None):
         super(Timestamp, self).__init__('TIMESTAMP', term, alias=alias)


Test patch:
diff --git a/pypika/tests/test_functions.py b/pypika/tests/test_functions.py
index e80d4b5..2f61784 100644
--- a/pypika/tests/test_functions.py
+++ b/pypika/tests/test_functions.py
@@ -594,6 +594,15 @@ class DateFunctionsTests(unittest.TestCase):
 
         self.assertEqual("SELECT CURRENT_TIME()", str(query))
 
+    def test_to_date(self):
+        q1 = fn.ToDate('2019-06-21', 'yyyy-mm-dd')
+        q2 = Query.from_(self.t).select(fn.ToDate('2019-06-21', 'yyyy-mm-dd'))
+        q3 = Query.from_(self.t).select(fn.ToDate(F('foo'), 'yyyy-mm-dd'))
+
+        self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')")
+        self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"")
+        self.assertEqual(str(q3), "SELECT TO_DATE(\"foo\",'yyyy-mm-dd') FROM \"abc\"")
+
 
 class NullFunctionsTests(unittest.TestCase):
     def test_isnull(self):
Repository: kayak/pypika
Pull request #292 (2019-08-08 19:22:52)

Fix bitwiseand
Hi, thanks for accepting my pull requests. I am very sorry but those was my first PR on github and I probably created branches badly and one of the merges actually deleted bitwiseand support..

This is just a fix to get it back. Everything same as in original PR.


Patch:
diff --git a/pypika/terms.py b/pypika/terms.py
index e765011..fad1ba8 100644
--- a/pypika/terms.py
+++ b/pypika/terms.py
@@ -102,6 +102,9 @@ class Term:
     def notnull(self):
         return self.isnull().negate()
 
+    def bitwiseand(self, value):
+        return BitwiseAndCriterion(self, value)
+
     def gt(self, other):
         return self > other
 
@@ -752,6 +755,40 @@ class BetweenCriterion(Criterion):
         return self.term.fields() if self.term.fields else []
 
 
+class BitwiseAndCriterion(Criterion):
+    def __init__(self, term, value, alias=None):
+        super(BitwiseAndCriterion, self).__init__(alias)
+        self.term = term
+        self.value = value
+
+    @property
+    def tables_(self):
+        return self.term.tables_
+
+    @builder
+    def replace_table(self, current_table, new_table):
+        """
+        Replaces all occurrences of the specified table with the new table. Useful when reusing fields across queries.
+
+        :param current_table:
+            The table to be replaced.
+        :param new_table:
+            The table to replace with.
+        :return:
+            A copy of the criterion with the tables replaced.
+        """
+        self.term = self.term.replace_table(current_table, new_table)
+
+    def get_sql(self, **kwargs):
+        return "({term} & {value})".format(
+                term=self.term.get_sql(**kwargs),
+                value=self.value,
+        )
+
+    def fields(self):
+        return self.term.fields() if self.term.fields else []
+
+
 class NullCriterion(Criterion):
     def __init__(self, term, alias=None):
         super(NullCriterion, self).__init__(alias)


Test patch:
diff --git a/pypika/tests/test_criterions.py b/pypika/tests/test_criterions.py
index e390725..c8f418b 100644
--- a/pypika/tests/test_criterions.py
+++ b/pypika/tests/test_criterions.py
@@ -245,6 +245,13 @@ class CriterionTests(unittest.TestCase):
         self.assertEqual('"foo">=1', str(c1))
         self.assertEqual('"crit"."foo">=-1', str(c2))
 
+    def test__criterion_bitwise_and(self):
+        c1 = Field("foo").bitwiseand(2)
+        c2 = Field("foo", table=self.t).bitwiseand(10) == 2
+
+        self.assertEqual('("foo" & 2)', str(c1))
+        self.assertEqual('("crit"."foo" & 10)=2', str(c2))
+
 
 class NotTests(unittest.TestCase):
     table_abc, table_efg = Table('abc', alias='cx0'), Table('efg', alias='cx1')
Repository: kayak/pypika
Pull request #301 (2019-08-20 21:21:53)

Add support for subqueries in JoinOn criterion
Subqueries aren't currently wrapped in parentheses when used in a `JOIN ON` criterion, similar to the issue reported in #220. This PR specifies `subquery=True` when calling `criterion.get_sql()` so that subqueries do get wrapped as expected. It also includes a corresponding test case in `test_joins.py`.

Note that the Python 3.4 tests are failing, but this is unrelated to these changes.


Patch:
diff --git a/pypika/queries.py b/pypika/queries.py
index ac8da5c..2b729bb 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -1191,7 +1191,7 @@ class JoinOn(Join):
         join_sql = super(JoinOn, self).get_sql(**kwargs)
         return '{join} ON {criterion}{collate}'.format(
               join=join_sql,
-              criterion=self.criterion.get_sql(**kwargs),
+              criterion=self.criterion.get_sql(subquery=True, **kwargs),
               collate=" COLLATE {}".format(self.collate) if self.collate else ""
         )
 


Test patch:
diff --git a/pypika/tests/test_joins.py b/pypika/tests/test_joins.py
index df7a6b7..c4b1f57 100644
--- a/pypika/tests/test_joins.py
+++ b/pypika/tests/test_joins.py
@@ -125,6 +125,17 @@ class SelectQueryJoinTests(unittest.TestCase):
         self.assertEqual('SELECT * FROM "abc" '
                          'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', str(q))
 
+    def test_join_on_subquery_criteria(self):
+        table_a, table_b, table_c = Tables('a', 'b', 'c')
+        subquery = Query.from_(table_c).select('id').limit(1)
+        query = Query.from_(table_a).select('*') \
+            .join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery))
+
+        self.assertEqual('SELECT * '
+                         'FROM "a" '
+                         'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"='
+                         '(SELECT "id" FROM "c" LIMIT 1)', str(query))
+
     def test_use_different_table_objects_for_same_table(self):
         table = Table("t")
         q = Query.from_(table).select('*').where(Field('id', table=table) == 1)
Repository: kayak/pypika
Pull request #305 (2019-08-22 00:16:14)

Implement ANSI SQL CURRENT_TIMESTAMP function
Hopefully this is the right approach.

Initially I thought I'd pattern it on the similar functions `CurDate` (for `CURRENT_DATE`) and `CurTime` (for `CURRENT_TIME`).  However, I found those implementations include empty parentheses in the generated SQL, such as `CURRENT_TIME()`, and that breaks `CURRENT_TIMESTAMP` on the platform I'm using (MSSQL).  

From I can tell, the parentheses aren't required by the standard, so this doesn't appear to be a platform quirk, so my implementation omits them.

The function seems like it probably has some overlap with the existing `Now` function, but since that one isn't supported by MSSQL and `CURRENT_TIMESTAMP` is part of ANSI SQL, I'm guessing it makes sense to include this in pypika.


Patch:
diff --git a/pypika/functions.py b/pypika/functions.py
index d4e527d..17295f9 100644
--- a/pypika/functions.py
+++ b/pypika/functions.py
@@ -243,6 +243,16 @@ class UtcTimestamp(Function):
         super(UtcTimestamp, self).__init__('UTC_TIMESTAMP', alias=alias)
 
 
+class CurTimestamp(Function):
+    def __init__(self, alias=None):
+        super(CurTimestamp, self).__init__('CURRENT_TIMESTAMP', alias=alias)
+
+    def get_function_sql(self, **kwargs):
+        # CURRENT_TIMESTAMP takes no arguments, so the SQL to generate is quite
+        # simple.  Note that empty parentheses have been omitted intentionally.
+        return 'CURRENT_TIMESTAMP'
+
+
 class CurDate(Function):
     def __init__(self, alias=None):
         super(CurDate, self).__init__('CURRENT_DATE', alias=alias)


Test patch:
diff --git a/pypika/tests/test_functions.py b/pypika/tests/test_functions.py
index 75f3a09..1daf4f8 100644
--- a/pypika/tests/test_functions.py
+++ b/pypika/tests/test_functions.py
@@ -604,6 +604,16 @@ class DateFunctionsTests(unittest.TestCase):
 
         self.assertEqual("SELECT CURRENT_TIME()", str(query))
 
+    def test_current_timestamp(self):
+        query = Query.select(fn.CurTimestamp())
+
+        self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query))
+
+    def test_current_timestamp_with_alias(self):
+        query = Query.select(fn.CurTimestamp('ts'))
+
+        self.assertEqual("SELECT CURRENT_TIMESTAMP \"ts\"", str(query))
+
     def test_to_date(self):
         q1 = fn.ToDate('2019-06-21', 'yyyy-mm-dd')
         q2 = Query.from_(self.t).select(fn.ToDate('2019-06-21', 'yyyy-mm-dd'))
Repository: kayak/pypika
Pull request #309 (2019-08-29 09:14:10)

Add snowflake dialect


Patch:
diff --git a/pypika/dialects.py b/pypika/dialects.py
index 5336f34..eb8a345 100644
--- a/pypika/dialects.py
+++ b/pypika/dialects.py
@@ -18,6 +18,24 @@ from pypika.utils import (
 )
 
 
+class SnowFlakeQueryBuilder(QueryBuilder):
+    QUOTE_CHAR = None
+
+    def __init__(self):
+        super(SnowFlakeQueryBuilder, self).__init__(quote_char=self.QUOTE_CHAR,
+                                                    dialect=Dialects.SNOWFLAKE)
+
+
+class SnowflakeQuery(Query):
+    """
+    Defines a query class for use with Snowflake.
+    """
+
+    @classmethod
+    def _builder(cls):
+        return SnowFlakeQueryBuilder()
+
+
 class MySQLQueryBuilder(QueryBuilder):
     QUOTE_CHAR = '`'
 
diff --git a/pypika/enums.py b/pypika/enums.py
index 5dae1fc..903cc6a 100644
--- a/pypika/enums.py
+++ b/pypika/enums.py
@@ -125,6 +125,7 @@ class Dialects(Enum):
     POSTGRESQL = 'postgressql'
     REDSHIFT = 'redshift'
     SQLLITE = 'sqllite'
+    SNOWFLAKE = 'snowflake'
 
 
 class PostgresOperators(Enum):


Test patch:
diff --git a/pypika/tests/dialects/test_snowflake.py b/pypika/tests/dialects/test_snowflake.py
new file mode 100644
index 0000000..2b3bcb7
--- /dev/null
+++ b/pypika/tests/dialects/test_snowflake.py
@@ -0,0 +1,13 @@
+import unittest
+
+from pypika import Table
+from pypika.dialects import SnowflakeQuery
+
+
+class QuoteTests(unittest.TestCase):
+    table_abc = Table('abc')
+
+    def test_no_double_quotes(self):
+        q = SnowflakeQuery.from_('abc').select('a')
+
+        self.assertEqual('SELECT a FROM abc', str(q))
Repository: kayak/pypika
Pull request #312 (2019-08-29 13:51:35)

Add aggregate function for vertica
Add the aggregate function 'APPROXIMATE_PERCENTILE' from vertica.


Patch:
diff --git a/pypika/functions.py b/pypika/functions.py
index 17295f9..d635cb2 100644
--- a/pypika/functions.py
+++ b/pypika/functions.py
@@ -87,6 +87,15 @@ class Floor(Function):
         super(Floor, self).__init__('FLOOR', term, alias=alias)
 
 
+class ApproximatePercentile(AggregateFunction):
+    def __init__(self, term, percentile, alias=None):
+        super(ApproximatePercentile, self).__init__('APPROXIMATE_PERCENTILE', term, alias=alias)
+        self.percentile = float(percentile)
+
+    def get_special_params_sql(self, **kwargs):
+        return 'USING PARAMETERS percentile={percentile}'.format(percentile=self.percentile)
+
+
 # Type Functions
 class Cast(Function):
     def __init__(self, term, as_type, alias=None):
diff --git a/pypika/terms.py b/pypika/terms.py
index fad1ba8..25a6087 100644
--- a/pypika/terms.py
+++ b/pypika/terms.py
@@ -1078,7 +1078,7 @@ class Function(Criterion):
     @property
     def is_aggregate(self):
         """
-        This is a shortcut thst assumes if a function has a single argument and that argument is aggregated, then this
+        This is a shortcut that assumes if a function has a single argument and that argument is aggregated, then this
         function is also aggregated. A more sophisticated approach is needed, however it is unclear how that might work.
         :returns:
             True if the function accepts one argument and that argument is aggregate.


Test patch:
diff --git a/pypika/tests/test_functions.py b/pypika/tests/test_functions.py
index 1daf4f8..f01273f 100644
--- a/pypika/tests/test_functions.py
+++ b/pypika/tests/test_functions.py
@@ -281,6 +281,11 @@ class AggregationTests(unittest.TestCase):
 
         self.assertEqual('SELECT STDDEV(\"foo\") FROM \"abc\"', str(q))
 
+    def test__approx_percentile(self):
+        q = Q.from_('abc').select(fn.ApproximatePercentile(F('foo'), 0.5))
+
+        self.assertEqual('SELECT APPROXIMATE_PERCENTILE(\"foo\" USING PARAMETERS percentile=0.5) FROM \"abc\"', str(q))
+
 
 class ConditionTests(unittest.TestCase):
     def test__case__raw(self):
Repository: kayak/pypika
Pull request #336 (2019-10-18 12:27:55)

Added missing parentheses
See this issue:

https://github.com/kayak/pypika/issues/335




Patch:
diff --git a/pypika/terms.py b/pypika/terms.py
index 97eaa56..a6271d9 100644
--- a/pypika/terms.py
+++ b/pypika/terms.py
@@ -708,11 +708,10 @@ class ContainsCriterion(Criterion):
     def fields(self):
         return self.term.fields() if self.term.fields else []
 
-    def get_sql(self, **kwargs):
-        # FIXME escape
+    def get_sql(self, subquery=None, **kwargs):
         return "{term} {not_}IN {container}".format(
               term=self.term.get_sql(**kwargs),
-              container=self.container.get_sql(**kwargs),
+              container=self.container.get_sql(subquery=True, **kwargs),
               not_='NOT ' if self._is_negated else ''
         )
 


Test patch:
diff --git a/pypika/tests/test_selects.py b/pypika/tests/test_selects.py
index c7dc5a8..d224ee5 100644
--- a/pypika/tests/test_selects.py
+++ b/pypika/tests/test_selects.py
@@ -794,6 +794,11 @@ class SubqueryTests(unittest.TestCase):
 
         self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', str(q))
 
+    def test_where__in_nested(self):
+        q = Query.from_(self.table_abc).select('*').where(self.table_abc.foo).isin(self.table_efg.select('*'))
+
+        self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q))
+
     def test_join(self):
         subquery = Query.from_('efg').select('fiz', 'buz').where(F('buz') == 0)
Repository: kayak/pypika
Pull request #373 (2020-02-07 16:47:27)

Support iterable params to columns
- Support iterable params(list, tuple) to columns 
- Add type checking in QueryBuilder colum methods

Fixed : #372 


Patch:
diff --git a/pypika/queries.py b/pypika/queries.py
index 92afea8..8dbc872 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -719,6 +719,9 @@ class QueryBuilder(Selectable, Term):
         if self._insert_table is None:
             raise AttributeError("'Query' object has no attribute '%s'" % "insert")
 
+        if isinstance(terms[0], (list, tuple)):
+            terms = terms[0]
+
         for term in terms:
             if isinstance(term, str):
                 term = Field(term, table=self._insert_table)


Test patch:
diff --git a/pypika/tests/test_inserts.py b/pypika/tests/test_inserts.py
index 92dbbc9..7f76208 100644
--- a/pypika/tests/test_inserts.py
+++ b/pypika/tests/test_inserts.py
@@ -111,6 +111,28 @@ class InsertIntoTests(unittest.TestCase):
             'INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)
         )
 
+    def test_insert_selected_columns_type_list(self):
+        query = (
+            Query.into(self.table_abc)
+            .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz])
+            .insert(1, "a", True)
+        )
+
+        self.assertEqual(
+            'INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)
+        )
+
+    def test_insert_selected_columns_type_tuple(self):
+        query = (
+            Query.into(self.table_abc)
+            .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz))
+            .insert(1, "a", True)
+        )
+
+        self.assertEqual(
+            'INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)
+        )
+
     def test_insert_none_skipped(self):
         query = Query.into(self.table_abc).insert()