PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: kayak/pypika (python)
Issue: Support and for Field and BetweenCriterion
`unsupported operand type(s) for &=: 'Field' and 'BetweenCriterion'` 


Pull request description: Fixes #134 Added missing boolean operation overrides to Field
Field was missing overrides for and, or, and xor which caused it to break if you tried to use it in a boolean expression.

Patch:
diff --git a/pypika/terms.py b/pypika/terms.py
index c0c7707..4e8f47f 100644
--- a/pypika/terms.py
+++ b/pypika/terms.py
@@ -259,6 +259,15 @@ class Field(Term):
         self.name = name
         self.table = table
 
+    def __and__(self, other):
+        return ComplexCriterion(Boolean.and_, self, other)
+
+    def __or__(self, other):
+        return ComplexCriterion(Boolean.or_, self, other)
+
+    def __xor__(self, other):
+        return ComplexCriterion(Boolean.xor_, self, other)
+
     @property
     def tables_(self):
         return {self.table}


Test patch:
diff --git a/pypika/tests/test_criterions.py b/pypika/tests/test_criterions.py
index aa2f901..670f0c2 100644
--- a/pypika/tests/test_criterions.py
+++ b/pypika/tests/test_criterions.py
@@ -1,8 +1,16 @@
 # coding: utf8
 import unittest
-from datetime import date, datetime
 
-from pypika import Field, Table, functions as fn
+from datetime import (
+    date,
+    datetime,
+)
+
+from pypika import (
+    Field,
+    Table,
+    functions as fn,
+)
 from pypika.terms import Mod
 
 __author__ = "Timothy Heys"
@@ -539,6 +547,33 @@ class ComplexCriterionTests(unittest.TestCase):
 
         self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c))
 
+    def test__between_and_field(self):
+        c1 = Field('foo').between(0, 1)
+        c2 = Field('bool_field')
+
+        self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2))
+        self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1))
+
+
+class FieldsAsCriterionTests(unittest.TestCase):
+    def test__field_and_field(self):
+        c1 = Field('a')
+        c2 = Field('b')
+
+        self.assertEqual('"a" AND "b"', str(c1 & c2))
+
+    def test__field_or_field(self):
+        c1 = Field('a')
+        c2 = Field('b')
+
+        self.assertEqual('"a" OR "b"', str(c1 | c2))
+
+    def test__field_xor_field(self):
+        c1 = Field('a')
+        c2 = Field('b')
+
+        self.assertEqual('"a" XOR "b"', str(c1 ^ c2))
+
 
 class CriterionOperationsTests(unittest.TestCase):
     table_abc, table_efg = Table('abc', alias='cx0'), Table('efg', alias='cx1')
Repository: spf13/afero (go)
Issue: MemMapFs does not respect os.O_EXCL
If `OpenFile` is called with `os.O_CREATE` and a file with the given path already exists, an `ErrFileExists` error should be returned.

While `OsFs` does support this, `MemMapFs` does not fail.
Pull request description: Add support for os.O_EXCL in afero.MemMapFs
Fixes #244 

Patch:
diff --git a/memmap.go b/memmap.go
index 943bad0..b7b1474 100644
--- a/memmap.go
+++ b/memmap.go
@@ -212,6 +212,9 @@ func (m *MemMapFs) lockfreeOpen(name string) (*mem.FileData, error) {
 func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
 	chmod := false
 	file, err := m.openWrite(name)
+	if err == nil && (flag&os.O_EXCL > 0) {
+		return nil, &os.PathError{Op: "open", Path: name, Err: ErrFileExists}
+	}
 	if os.IsNotExist(err) && (flag&os.O_CREATE > 0) {
 		file, err = m.Create(name)
 		chmod = true


Test patch:
diff --git a/memmap_test.go b/memmap_test.go
index 47414ab..a88ea30 100644
--- a/memmap_test.go
+++ b/memmap_test.go
@@ -104,6 +104,29 @@ func checkPathError(t *testing.T, err error, op string) {
 	}
 }
 
+// Ensure os.O_EXCL is correctly handled.
+func TestOpenFileExcl(t *testing.T) {
+	const fileName = "/myFileTest"
+	const fileMode = os.FileMode(0765)
+
+	fs := NewMemMapFs()
+
+	// First creation should succeed.
+	f, err := fs.OpenFile(fileName, os.O_CREATE|os.O_EXCL, fileMode)
+	if err != nil {
+		t.Errorf("OpenFile Create Excl failed: %s", err)
+		return
+	}
+	f.Close()
+
+	// Second creation should fail.
+	_, err = fs.OpenFile(fileName, os.O_CREATE|os.O_EXCL, fileMode)
+	if err == nil {
+		t.Errorf("OpenFile Create Excl should have failed, but it didn't")
+	}
+	checkPathError(t, err, "Open")
+}
+
 // Ensure Permissions are set on OpenFile/Mkdir/MkdirAll
 func TestPermSet(t *testing.T) {
 	const fileName = "/myFileTest"