Skip to content

Commit 6f1db88

Browse files
authored
fix: Don't lose IP data in AppendValueFromString (#2236)
#### Summary Reverts #2205 as we were actually losing the IP data in some cases (in `AppendValueFromString`). This PR ensures we don't lose the IP data ---
1 parent 3955c1d commit 6f1db88

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

schema/testdata.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/base64"
66
"fmt"
77
"math/rand"
8-
"net"
98
"strconv"
109
"strings"
1110
"time"
@@ -317,11 +316,9 @@ func (tg TestDataGenerator) getExampleJSON(colName string, dataType arrow.DataTy
317316

318317
// Generate a CIDR prefix length between 8 and 30
319318
cidr := 8 + rnd.Intn(23)
320-
input := fmt.Sprintf(`%d.%d.%d.%d/%d`, ip[0], ip[1], ip[2], ip[3], cidr)
321-
_, data, _ := net.ParseCIDR(input)
322319

323320
// Format as an IP address with CIDR notation
324-
return fmt.Sprintf(`"%s"`, data.String())
321+
return fmt.Sprintf(`"%d.%d.%d.%d/%d"`, ip[0], ip[1], ip[2], ip[3], cidr)
325322
}
326323
if arrow.TypeEqual(dataType, types.ExtensionTypes.MAC) {
327324
mac := make([]byte, 6)

types/inet.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ func (b *InetBuilder) AppendValueFromString(s string) error {
5353
b.AppendNull()
5454
return nil
5555
}
56-
_, data, err := net.ParseCIDR(s)
56+
ip, data, err := net.ParseCIDR(s)
5757
if err != nil {
5858
return err
5959
}
60+
data.IP = ip
6061
b.Append(data)
6162
return nil
6263
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy