nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jackc/pgx
Pull request #1498 (2023-02-10 17:58:57)

Register pgx driver using major version
Fixed: #1480


Patch:
diff --git a/pgtype/pgtype.go b/pgtype/pgtype.go
index 7dcdc68b..7b300709 100644
--- a/pgtype/pgtype.go
+++ b/pgtype/pgtype.go
@@ -1028,7 +1028,7 @@ func TryWrapStructScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValu
 
 	var targetElemValue reflect.Value
 	if targetValue.IsNil() {
-		targetElemValue = reflect.New(targetValue.Type().Elem())
+		targetElemValue = reflect.Zero(targetValue.Type().Elem())
 	} else {
 		targetElemValue = targetValue.Elem()
 	}
diff --git a/stdlib/sql.go b/stdlib/sql.go
index 44e82d98..ddb15ff6 100644
--- a/stdlib/sql.go
+++ b/stdlib/sql.go
@@ -66,6 +66,7 @@ import (
 	"math"
 	"math/rand"
 	"reflect"
+	"sort"
 	"strconv"
 	"strings"
 	"sync"
@@ -85,7 +86,13 @@ func init() {
 	pgxDriver = &Driver{
 		configs: make(map[string]*pgx.ConnConfig),
 	}
-	sql.Register("pgx", pgxDriver)
+
+	drivers := sql.Drivers()
+	// if pgx driver was already registered by different pgx major version then we skip registration under the default name.
+	if i := sort.SearchStrings(sql.Drivers(), "pgx"); len(drivers) >= i || drivers[i] != "pgx" {
+		sql.Register("pgx", pgxDriver)
+	}
+	sql.Register("pgx/v5", pgxDriver)
 
 	databaseSQLResultFormats = pgx.QueryResultFormatsByOID{
 		pgtype.BoolOID:        1,


Test patch:
diff --git a/pgtype/pgtype_test.go b/pgtype/pgtype_test.go
index 5574b676..60863f49 100644
--- a/pgtype/pgtype_test.go
+++ b/pgtype/pgtype_test.go
@@ -291,6 +291,34 @@ func TestScanPlanInterface(t *testing.T) {
 	assert.Error(t, err)
 }
 
+func TestPointerPointerStructScan(t *testing.T) {
+	m := pgtype.NewMap()
+	type composite struct {
+		ID int
+	}
+
+	int4Type, _ := m.TypeForOID(pgtype.Int4OID)
+	pgt := &pgtype.Type{
+		Codec: &pgtype.CompositeCodec{
+			Fields: []pgtype.CompositeCodecField{
+				{
+					Name: "id",
+					Type: int4Type,
+				},
+			},
+		},
+		Name: "composite",
+		OID:  215333,
+	}
+	m.RegisterType(pgt)
+
+	var c *composite
+	plan := m.PlanScan(pgt.OID, pgtype.TextFormatCode, &c)
+	err := plan.Scan([]byte("(1)"), &c)
+	require.NoError(t, err)
+	require.Equal(t, c.ID, 1)
+}
+
 // https://github.com/jackc/pgx/issues/1263
 func TestMapScanPtrToPtrToSlice(t *testing.T) {
 	m := pgtype.NewMap()
diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go
index 314f460b..00fbbb72 100644
--- a/stdlib/sql_test.go
+++ b/stdlib/sql_test.go
@@ -146,9 +146,22 @@ func closeStmt(t *testing.T, stmt *sql.Stmt) {
 }
 
 func TestSQLOpen(t *testing.T) {
-	db, err := sql.Open("pgx", os.Getenv("PGX_TEST_DATABASE"))
-	require.NoError(t, err)
-	closeDB(t, db)
+	tests := []struct {
+		driverName string
+	}{
+		{driverName: "pgx"},
+		{driverName: "pgx/v5"},
+	}
+
+	for _, tt := range tests {
+		tt := tt
+
+		t.Run(tt.driverName, func(t *testing.T) {
+			db, err := sql.Open(tt.driverName, os.Getenv("PGX_TEST_DATABASE"))
+			require.NoError(t, err)
+			closeDB(t, db)
+		})
+	}
 }
 
 func TestNormalLifeCycle(t *testing.T) {
Repository: mswjs/msw
Pull request #2403 (2024-12-29 02:37:37)

fix: support nullable GraphQL queries
Hello, thank you for developing this wonderful library called msw. I am using msw in my graphql project. There I have a Query with nullable return value.
And I generate that type using graphql-codegen.
Here is an example of the generated type.

```ts
export type Maybe<T> = T | null;

export type IQuery = {
  __typename?: 'Query';
  authUser: Maybe<IUser>;
  user: Maybe<IUser>;
};
```

And I tried to use this query type which may return null in graphql.query and graphql.mutation.

```ts
import { graphql } from 'msw';

graphql.query<IQuery['authUser'], /* variable type */>(queryName, () => {});
graphql.mutation</* nullable mutation */, /* variable type */>(queryName, () => {});
```

Then I got a type error that nullable queries and mutations are not supported.

I would like to have the actual value returned by a query or mutation set strictly as a type in mock as well.
Therefore, I have modified `GraphQLQuery` to allow null.
What do you think?


Patch:
diff --git a/src/core/handlers/GraphQLHandler.ts b/src/core/handlers/GraphQLHandler.ts
index aeccc627..8aebee5e 100644
--- a/src/core/handlers/GraphQLHandler.ts
+++ b/src/core/handlers/GraphQLHandler.ts
@@ -24,7 +24,7 @@ import { getAllRequestCookies } from '../utils/request/getRequestCookies'
 export type ExpectedOperationTypeNode = OperationTypeNode | 'all'
 export type GraphQLHandlerNameSelector = DocumentNode | RegExp | string
 
-export type GraphQLQuery = Record<string, any>
+export type GraphQLQuery = Record<string, any> | null
 export type GraphQLVariables = Record<string, any>
 
 export interface GraphQLHandlerInfo extends RequestHandlerDefaultInfo {


Test patch:
diff --git a/test/typings/graphql.test-d.ts b/test/typings/graphql.test-d.ts
index 4d7a1976..28242c2b 100644
--- a/test/typings/graphql.test-d.ts
+++ b/test/typings/graphql.test-d.ts
@@ -75,6 +75,22 @@ it('graphql query allows explicit null as the response body type for the query',
   })
 })
 
+it('supports nullable queries', () => {
+  graphql.query<{ id: string } | null>('GetUser', () => {
+    return HttpResponse.json({
+      data: null,
+    })
+  })
+})
+
+it('supports nullable mutations', () => {
+  graphql.mutation<{ id: string } | null>('GetUser', () => {
+    return HttpResponse.json({
+      data: null,
+    })
+  })
+})
+
 it('graphql query does not accept invalid data type for the response body type for the query', () => {
   graphql.query<{ id: string }>('GetUser', () => {
     return HttpResponse.json({
Repository: mswjs/msw
Pull request #2544 (2025-07-04 12:52:46)

fix(ws): support `resolutionContext` on `parse` and `run`
This change allows the user to specify relative WebSocket connection URLs and have them resolved against `resolutionContext?.baseUrl` during the request matching. 

pkg-pr-new[bot]: 
[Open in StackBlitz](https://pkg.pr.new/template/dc41ae77-b8c2-4f3a-8e0f-a8384d5d3af4)


```
npm i https://pkg.pr.new/msw@2544
```


_commit: <a href="https://github.com/mswjs/msw/runs/45365878947"><code>11577d8</code></a>_


Patch:
diff --git a/src/core/handlers/WebSocketHandler.ts b/src/core/handlers/WebSocketHandler.ts
index d39a10fe..22ea65f6 100644
--- a/src/core/handlers/WebSocketHandler.ts
+++ b/src/core/handlers/WebSocketHandler.ts
@@ -29,6 +29,10 @@ export interface WebSocketHandlerConnection {
   params: PathParams
 }
 
+export interface WebSocketResolutionContext {
+  baseUrl?: string
+}
+
 export const kEmitter = Symbol('kEmitter')
 export const kSender = Symbol('kSender')
 const kStopPropagationPatched = Symbol('kStopPropagationPatched')
@@ -50,7 +54,10 @@ export class WebSocketHandler {
     this.__kind = 'EventHandler'
   }
 
-  public parse(args: { url: URL }): WebSocketHandlerParsedResult {
+  public parse(args: {
+    url: URL
+    resolutionContext?: WebSocketResolutionContext
+  }): WebSocketHandlerParsedResult {
     const clientUrl = new URL(args.url)
 
     /**
@@ -60,7 +67,11 @@ export class WebSocketHandler {
      */
     clientUrl.pathname = clientUrl.pathname.replace(/^\/socket.io\//, '/')
 
-    const match = matchRequestUrl(clientUrl, this.url)
+    const match = matchRequestUrl(
+      clientUrl,
+      this.url,
+      args.resolutionContext?.baseUrl,
+    )
 
     return {
       match,
@@ -76,9 +87,11 @@ export class WebSocketHandler {
 
   public async run(
     connection: Omit<WebSocketHandlerConnection, 'params'>,
+    resolutionContext?: WebSocketResolutionContext,
   ): Promise<boolean> {
     const parsedResult = this.parse({
       url: connection.client.url,
+      resolutionContext,
     })
 
     if (!this.predicate({ url: connection.client.url, parsedResult })) {


Test patch:
diff --git a/src/core/handlers/WebSocketHandler.test.ts b/src/core/handlers/WebSocketHandler.test.ts
index 53c58875..e7a881aa 100644
--- a/src/core/handlers/WebSocketHandler.test.ts
+++ b/src/core/handlers/WebSocketHandler.test.ts
@@ -108,4 +108,20 @@ describe('parse', () => {
       },
     })
   })
+
+  it('supports a custom resolution context (base url)', () => {
+    expect(
+      new WebSocketHandler('/api/ws').parse({
+        url: new URL('ws://localhost:3000/api/ws'),
+        resolutionContext: {
+          baseUrl: 'ws://localhost:3000/',
+        },
+      }),
+    ).toEqual({
+      match: {
+        matches: true,
+        params: {},
+      },
+    })
+  })
 })