nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: tediousjs/node-mssql
Pull request #990 (2020-02-15 07:45:52)

Fix issue with tagged template literal query with empty array
This fixes issue #989


Patch:
diff --git a/lib/base/request.js b/lib/base/request.js
index 4c0f2f8..586928a 100644
--- a/lib/base/request.js
+++ b/lib/base/request.js
@@ -78,10 +78,9 @@ class Request extends EventEmitter {
           command.push(`@param${index + 1}_${parameterIndex}`)
           if (parameterIndex < value.length - 1) {
             command.push(', ')
-          } else {
-            command.push(strings[index + 1])
           }
         }
+        command.push(strings[index + 1])
       } else {
         this.input(`param${index + 1}`, value)
         command.push(`@param${index + 1}`, strings[index + 1])


Test patch:
diff --git a/test/common/unit.js b/test/common/unit.js
index c4dd0e1..453288c 100644
--- a/test/common/unit.js
+++ b/test/common/unit.js
@@ -272,6 +272,11 @@ describe('Unit', () => {
       input: [['param1_0', 1], ['param1_1', 2], ['param1_2', 3]],
       command: 'select * from myTable where id in (@param1_0, @param1_1, @param1_2)'
     })
+
+    assert.deepStrictEqual(query`select * from myTable where id in (${[]})`, {
+      input: [],
+      command: 'select * from myTable where id in ()'
+    })
   })
 
   it('tagged template literal request', () => {
Repository: tediousjs/node-mssql
Pull request #1397 (2022-05-27 14:56:38)

fix missing square bracket on constraint

Incapsulate primary key constraint with square brackets





Patch:
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 36e0122..f28ebeb 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,7 @@
+v7.3.5 (2022-05-27)
+-------------------
+[fix] quote identifiers in table constraint declaration ([#1397](https://github.com/tediousjs/node-mssql/pull/1397))
+
 v7.3.4 (2022-05-18)
 -------------------
 [fix] msnodesqlv8.js file was missing from previous release
diff --git a/lib/table.js b/lib/table.js
index 87a4ec4..1a17731 100644
--- a/lib/table.js
+++ b/lib/table.js
@@ -109,7 +109,7 @@ Table.prototype.declare = function declare () {
     return def.join(' ')
   })
 
-  const constraint = pkey.length > 1 ? `, constraint PK_${this.temporary ? this.name.substr(1) : this.name} primary key (${pkey.join(', ')})` : ''
+  const constraint = pkey.length > 1 ? `, constraint [PK_${this.temporary ? this.name.substr(1) : this.name}] primary key (${pkey.join(', ')})` : ''
   return `create table ${this.path} (${cols.join(', ')}${constraint})`
 }
 


Test patch:
diff --git a/test/common/unit.js b/test/common/unit.js
index 5c7f7dd..a5f238a 100644
--- a/test/common/unit.js
+++ b/test/common/unit.js
@@ -198,7 +198,7 @@ describe('Unit', () => {
     t.columns.add('a', sql.Int, { primary: true })
     t.columns.add('b', sql.TinyInt, { nullable: true })
     t.columns.add('c', sql.TinyInt, { nullable: false, primary: true })
-    assert.strictEqual(t.declare(), 'create table [#mytemptable] ([a] int, [b] tinyint null, [c] tinyint not null, constraint PK_mytemptable primary key ([a], [c]))')
+    assert.strictEqual(t.declare(), 'create table [#mytemptable] ([a] int, [b] tinyint null, [c] tinyint not null, constraint [PK_mytemptable] primary key ([a], [c]))')
 
     t = new sql.Table('MyTable')
     t.columns.add('name', sql.NVarChar, {
Repository: tefra/xsdata
Pull request #836 (2023-07-24 06:40:43)

Drop all wildcards from mixed content choices
## 📒 Description

Until now we ignored `xs:any` elements, but elements without a type are also wildcards.

## 🔗 What I've Done

> Write a description of the steps taken to resolve the issue


## 💬 Comments

> A place to write any comments to the reviewer.
>

## 🛫 Checklist

- [ ] Updated docs
- [ ] Added unit-tests
- [ ] [Sample tests](https://github.com/tefra/xsdata-samples) pass
- [ ] [W3C tests](https://github.com/tefra/xsdata-w3c-tests) pass



Patch:
diff --git a/xsdata/codegen/handlers/process_mixed_content_class.py b/xsdata/codegen/handlers/process_mixed_content_class.py
index 23071f19..68313a9e 100644
--- a/xsdata/codegen/handlers/process_mixed_content_class.py
+++ b/xsdata/codegen/handlers/process_mixed_content_class.py
@@ -31,7 +31,7 @@ class ProcessMixedContentClass(HandlerInterface):
         for attr in list(target.attrs):
             if attr.is_attribute:
                 attrs.append(attr)
-            elif attr.tag != Tag.ANY:
+            elif not attr.is_any_type:
                 choice = attr.clone()
                 choice.restrictions.min_occurs = None
                 choice.restrictions.max_occurs = None


Test patch:
diff --git a/tests/codegen/handlers/test_process_mixed_content_class.py b/tests/codegen/handlers/test_process_mixed_content_class.py
index 58452950..6fccaa2e 100644
--- a/tests/codegen/handlers/test_process_mixed_content_class.py
+++ b/tests/codegen/handlers/test_process_mixed_content_class.py
@@ -20,12 +20,13 @@ class ProcessMixedContentClassTests(FactoryTestCase):
             AttrFactory.attribute(),  # keep
             AttrFactory.reference("foo", restrictions=res.clone()),  # choice
             AttrFactory.native(DataType.INT, restrictions=res.clone()),  # choice
+            AttrFactory.native(DataType.ANY_TYPE, restrictions=res.clone()),  # drop
             AttrFactory.any(),  # drop
         ]
         item = ClassFactory.create(attrs=attrs)
 
         self.processor.process(item)
-        self.assertEqual(4, len(item.attrs))
+        self.assertEqual(5, len(item.attrs))
 
         item.mixed = True
         self.processor.process(item)
@@ -39,7 +40,7 @@ class ProcessMixedContentClassTests(FactoryTestCase):
         expected.restrictions.min_occurs = 0
         expected.restrictions.max_occurs = sys.maxsize
         choices = []
-        for attr in attrs[1:-1]:
+        for attr in attrs[1:-2]:
             choice = attr.clone()
             choice.restrictions.min_occurs = None
             choice.restrictions.max_occurs = None
Repository: tefra/xsdata
Pull request #837 (2023-07-24 06:59:14)

Fix bind wild text with only tail
## 📒 Description

Fix issue when node has a tail but no text.

`<doc><b/>text<a/>text<d/>text<a/></doc>`

In this scenario we need to prepend `None` in the list otherwise tail becomes text


## 🔗 What I've Done

> Write a description of the steps taken to resolve the issue


## 💬 Comments

> A place to write any comments to the reviewer.
>

## 🛫 Checklist

- [ ] Updated docs
- [ ] Added unit-tests
- [ ] [Sample tests](https://github.com/tefra/xsdata-samples) pass
- [ ] [W3C tests](https://github.com/tefra/xsdata-w3c-tests) pass



Patch:
diff --git a/xsdata/formats/dataclass/parsers/nodes/element.py b/xsdata/formats/dataclass/parsers/nodes/element.py
index 7fca3e4c..d9c97cc3 100644
--- a/xsdata/formats/dataclass/parsers/nodes/element.py
+++ b/xsdata/formats/dataclass/parsers/nodes/element.py
@@ -311,10 +311,12 @@ class ElementNode(XmlNode):
             if items is None:
                 params[var.name] = items = PendingCollection(None, var.factory)
 
-            if txt:
-                items.insert(0, txt)
             if tail:
                 items.append(tail)
+
+            if txt or tail:
+                items.insert(0, txt)
+
         else:
             previous = params.get(var.name, None)
             factory = self.context.class_type.any_element


Test patch:
diff --git a/tests/formats/dataclass/parsers/nodes/test_element.py b/tests/formats/dataclass/parsers/nodes/test_element.py
index 37eaa936..4a52f63a 100644
--- a/tests/formats/dataclass/parsers/nodes/test_element.py
+++ b/tests/formats/dataclass/parsers/nodes/test_element.py
@@ -174,10 +174,10 @@ class ElementNodeTests(FactoryTestCase):
         self.assertEqual({"wildcard": ["txt", "tail"]}, params)
 
         self.node.bind_wild_text(params, var, None, "tail")
-        self.assertEqual({"wildcard": ["txt", "tail", "tail"]}, params)
+        self.assertEqual({"wildcard": [None, "txt", "tail", "tail"]}, params)
 
         self.node.bind_wild_text(params, var, "first", None)
-        self.assertEqual({"wildcard": ["first", "txt", "tail", "tail"]}, params)
+        self.assertEqual({"wildcard": ["first", None, "txt", "tail", "tail"]}, params)
 
     def test_bind_attrs(self):
         self.node.meta = self.context.build(AttrsType)
Repository: tefra/xsdata
Pull request #838 (2023-07-24 15:20:05)

Pycodeserializer should import inner classes
## 📒 Description

> Write a brief description of your PR.


Resolves #xxxx

## 🔗 What I've Done

> Write a description of the steps taken to resolve the issue


## 💬 Comments

> A place to write any comments to the reviewer.
>

## 🛫 Checklist

- [ ] Updated docs
- [ ] Added unit-tests
- [ ] [Sample tests](https://github.com/tefra/xsdata-samples) pass
- [ ] [W3C tests](https://github.com/tefra/xsdata-w3c-tests) pass



Patch:
diff --git a/xsdata/formats/dataclass/serializers/code.py b/xsdata/formats/dataclass/serializers/code.py
index 1d219c40..1f46bf49 100644
--- a/xsdata/formats/dataclass/serializers/code.py
+++ b/xsdata/formats/dataclass/serializers/code.py
@@ -69,14 +69,17 @@ class PycodeSerializer(AbstractSerializer):
 
     @classmethod
     def build_imports(cls, types: Set[Type]) -> str:
-        imports = []
+        imports = set()
         for tp in types:
             module = tp.__module__
             name = tp.__qualname__
-            if module != "builtins" and "." not in name:
-                imports.append(f"from {module} import {name}\n")
+            if module != "builtins":
+                if "." in name:
+                    name = name.split(".")[0]
 
-        return "".join(sorted(imports))
+                imports.add(f"from {module} import {name}\n")
+
+        return "".join(sorted(set(imports)))
 
     def write_object(self, obj: Any, level: int, types: Set[Type]):
         types.add(type(obj))


Test patch:
diff --git a/tests/formats/dataclass/serializers/test_code.py b/tests/formats/dataclass/serializers/test_code.py
index 0485a836..3e05c773 100644
--- a/tests/formats/dataclass/serializers/test_code.py
+++ b/tests/formats/dataclass/serializers/test_code.py
@@ -3,6 +3,7 @@ from unittest import TestCase
 from tests.fixtures.books import BookForm
 from tests.fixtures.books import Books
 from tests.fixtures.books.fixtures import books
+from tests.fixtures.models import Parent
 from xsdata.formats.dataclass.serializers import PycodeSerializer
 from xsdata.models.enums import Namespace
 
@@ -85,9 +86,7 @@ class PycodeSerializerTests(TestCase):
         iterator = self.serializer.write_object(Namespace.SOAP11, 0, set())
         self.assertEqual("Namespace.SOAP11", "".join(iterator))
 
-    def test_build_imports_ignores_nested_types(self):
-        class Foo:
-            pass
-
-        actual = self.serializer.build_imports({Foo})
-        self.assertEqual("", actual)
+    def test_build_imports_with_nested_types(self):
+        expected = "from tests.fixtures.models import Parent\n"
+        actual = self.serializer.build_imports({Parent.Inner})
+        self.assertEqual(expected, actual)