nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cosmos/relayer
Pull request #989 (2022-09-16 05:50:41)

Default to events processor


Patch:
diff --git a/cmd/flags.go b/cmd/flags.go
index 8f56e9e..a1ba4fa 100644
--- a/cmd/flags.go
+++ b/cmd/flags.go
@@ -293,7 +293,7 @@ func debugServerFlags(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
 }
 
 func processorFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
-	cmd.Flags().StringP(flagProcessor, "p", relayer.ProcessorLegacy, "which relayer processor to use")
+	cmd.Flags().StringP(flagProcessor, "p", relayer.ProcessorEvents, "which relayer processor to use")
 	if err := v.BindPFlag(flagProcessor, cmd.Flags().Lookup(flagProcessor)); err != nil {
 		panic(err)
 	}
diff --git a/relayer/strategies.go b/relayer/strategies.go
index bd5cf85..5e1360a 100644
--- a/relayer/strategies.go
+++ b/relayer/strategies.go
@@ -72,7 +72,7 @@ func StartRelayer(
 		return errorChan
 	case ProcessorLegacy:
 		if len(paths) != 1 {
-			panic(fmt.Errorf("only one path supported for legacy processor. pass `-p events` for multiple paths"))
+			panic(errors.New("only one path supported for legacy processor"))
 		}
 		p := paths[0].Path
 		src, dst := chains[p.Src.ChainID], chains[p.Dst.ChainID]


Test patch:
diff --git a/ibctest/relay_many_test.go b/ibctest/relay_many_test.go
index 88ce9a2..3c6986d 100644
--- a/ibctest/relay_many_test.go
+++ b/ibctest/relay_many_test.go
@@ -29,7 +29,6 @@ func TestRelayerMultiplePathsSingleProcess(t *testing.T) {
 		zaptest.NewLogger(t),
 		ibctestrelayer.CustomDockerImage(relayeribctest.RelayerImageName, "latest", "100:1000"),
 		ibctestrelayer.ImagePull(false),
-		ibctestrelayer.StartupFlags("-p", "events"),
 	).Build(t, client, network)
 
 	rep := testreporter.NewNopReporter()
Repository: ariga/atlas
Pull request #235 (2021-11-17 12:01:42)

sql/postgres: add spec types

yonidavidson: @hilakashai great work finding the problems! really helped me solve it quickly !!

Patch:
diff --git a/sql/postgres/sqlspec.go b/sql/postgres/sqlspec.go
index f0b343f1..c42b51c0 100644
--- a/sql/postgres/sqlspec.go
+++ b/sql/postgres/sqlspec.go
@@ -270,7 +270,7 @@ func columnTypeSpec(t schema.Type) (*sqlspec.Column, error) {
 
 func stringSpec(t *schema.StringType) (*sqlspec.Column, error) {
 	switch t.T {
-	case tVarChar, tText:
+	case tVarChar, tText, tChar, tCharacter, tCharVar:
 		s := strconv.Itoa(t.Size)
 		return specutil.NewCol("", "string", specutil.LitAttr("size", s)), nil
 	default:
@@ -280,7 +280,7 @@ func stringSpec(t *schema.StringType) (*sqlspec.Column, error) {
 
 func integerSpec(t *schema.IntegerType) (*sqlspec.Column, error) {
 	switch t.T {
-	case tInt:
+	case tInt, tInteger:
 		if t.Unsigned {
 			return specutil.NewCol("", "uint"), nil
 		}
@@ -291,7 +291,7 @@ func integerSpec(t *schema.IntegerType) (*sqlspec.Column, error) {
 		}
 		return &sqlspec.Column{TypeName: "int64"}, nil
 	default:
-		return nil, errors.New("schema integer failed to convert")
+		return &sqlspec.Column{TypeName: t.T}, nil
 	}
 }
 


Test patch:
diff --git a/sql/postgres/sqlspec_test.go b/sql/postgres/sqlspec_test.go
index f6db34a0..faeccea7 100644
--- a/sql/postgres/sqlspec_test.go
+++ b/sql/postgres/sqlspec_test.go
@@ -312,6 +312,34 @@ func TestMarshalSpecColumnType(t *testing.T) {
 			},
 			expected: specutil.NewCol("int64", "int64"),
 		},
+		{
+			schem: &schema.IntegerType{
+				T:        tInteger,
+				Unsigned: false,
+			},
+			expected: specutil.NewCol("integer", "int"),
+		},
+		{
+			schem: &schema.IntegerType{
+				T:        tInt2,
+				Unsigned: false,
+			},
+			expected: specutil.NewCol("int2", tInt2),
+		},
+		{
+			schem: &schema.IntegerType{
+				T:        tInt4,
+				Unsigned: false,
+			},
+			expected: specutil.NewCol("int4", tInt4),
+		},
+		{
+			schem: &schema.IntegerType{
+				T:        tInt8,
+				Unsigned: false,
+			},
+			expected: specutil.NewCol("int8", tInt8),
+		},
 		{
 			schem: &schema.StringType{
 				T:    tVarChar,
@@ -319,6 +347,27 @@ func TestMarshalSpecColumnType(t *testing.T) {
 			},
 			expected: specutil.NewCol("string_varchar", "string", specutil.LitAttr("size", "255")),
 		},
+		{
+			schem: &schema.StringType{
+				T:    tChar,
+				Size: 255,
+			},
+			expected: specutil.NewCol("string_tchar", "string", specutil.LitAttr("size", "255")),
+		},
+		{
+			schem: &schema.StringType{
+				T:    tCharacter,
+				Size: 255,
+			},
+			expected: specutil.NewCol("string_Character", "string", specutil.LitAttr("size", "255")),
+		},
+		{
+			schem: &schema.StringType{
+				T:    tCharVar,
+				Size: 255,
+			},
+			expected: specutil.NewCol("string_CharVar", "string", specutil.LitAttr("size", "255")),
+		},
 		{
 			schem: &schema.StringType{
 				T:    tText,
Repository: ariga/atlas
Pull request #258 (2021-11-28 13:16:24)

sql/postgres: normalize array types on unmarshal


Patch:
diff --git a/sql/postgres/sqlspec.go b/sql/postgres/sqlspec.go
index 961b4393..89c6ef10 100644
--- a/sql/postgres/sqlspec.go
+++ b/sql/postgres/sqlspec.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"strconv"
 	"strings"
+	"unicode"
 
 	"ariga.io/atlas/schema/schemaspec"
 	"ariga.io/atlas/sql/internal/specutil"
@@ -196,11 +197,16 @@ func convertFloat(spec *sqlspec.Column) (schema.Type, error) {
 }
 
 func parseRawType(spec *sqlspec.Column) (schema.Type, error) {
-	cm, err := parseColumn(spec.TypeName)
+	d, err := parseColumn(spec.TypeName)
 	if err != nil {
 		return nil, err
 	}
-	return columnType(cm), nil
+	// Normalize PostgreSQL array data types from "CREATE TABLE" format to
+	// "INFORMATION_SCHEMA" format (i.e. as it is inspected from the database).
+	if t, ok := arrayType(spec.TypeName); ok {
+		d = &columnDesc{typ: tArray, udt: t}
+	}
+	return columnType(d), nil
 }
 
 // schemaSpec converts from a concrete Postgres schema to Atlas specification.
@@ -335,3 +341,18 @@ func bitSpec(t *BitType) (*sqlspec.Column, error) {
 		return nil, errors.New("schema bit failed to convert")
 	}
 }
+
+// arrayType reports if the given string is an array type (e.g. int[], text[2]),
+// and returns its "udt_name" as it was inspected from the database.
+func arrayType(t string) (string, bool) {
+	i, j := strings.LastIndexByte(t, '['), strings.LastIndexByte(t, ']')
+	if i == -1 || j == -1 {
+		return "", false
+	}
+	for _, r := range t[i+1 : j] {
+		if !unicode.IsDigit(r) {
+			return "", false
+		}
+	}
+	return t[:strings.IndexByte(t, '[')], true
+}


Test patch:
diff --git a/internal/integration/postgres_test.go b/internal/integration/postgres_test.go
index 2a8e1e47..81f30429 100644
--- a/internal/integration/postgres_test.go
+++ b/internal/integration/postgres_test.go
@@ -386,6 +386,9 @@ table "posts" {
 	column "id" {
 		type = "int"
 	}
+	column "tags" {
+		type = "text[]"
+	}
 	column "author_id" {
 		type = "int"
 	}
diff --git a/sql/postgres/sqlspec_test.go b/sql/postgres/sqlspec_test.go
index 8f01012f..9a9d97de 100644
--- a/sql/postgres/sqlspec_test.go
+++ b/sql/postgres/sqlspec_test.go
@@ -235,6 +235,14 @@ func TestUnmarshalSpecColumnTypes(t *testing.T) {
 			spec:     specutil.NewCol("bit8", "bit(8)"),
 			expected: &BitType{T: tBit, Len: 8},
 		},
+		{
+			spec:     specutil.NewCol("texts", "text[]"),
+			expected: &ArrayType{T: "text[]"},
+		},
+		{
+			spec:     specutil.NewCol("texts", "text[2]"),
+			expected: &ArrayType{T: "text[]"},
+		},
 	} {
 		t.Run(tt.spec.Name, func(t *testing.T) {
 			var s schema.Schema