mirror of
https://github.com/nxshock/mssqlbulkloader.git
synced 2024-11-28 00:21:03 +05:00
Compare commits
4 Commits
92f089b828
...
3e96fdbb35
Author | SHA1 | Date | |
---|---|---|---|
3e96fdbb35 | |||
143ba6aae2 | |||
81729ffcd0 | |||
ab95f49c96 |
@ -41,8 +41,10 @@ func (ft FieldType) ParseValue(reader Reader, s string) (any, error) {
|
|||||||
return s, nil
|
return s, nil
|
||||||
case Integer:
|
case Integer:
|
||||||
return strconv.ParseInt(s, 10, 64)
|
return strconv.ParseInt(s, 10, 64)
|
||||||
case Float:
|
case Float, Money:
|
||||||
return strconv.ParseFloat(strings.ReplaceAll(s, ",", "."), 64)
|
s = strings.ReplaceAll(s, ",", ".")
|
||||||
|
s = strings.ReplaceAll(s, " ", "")
|
||||||
|
return strconv.ParseFloat(s, 64)
|
||||||
case Date:
|
case Date:
|
||||||
if i, ok := reader.(CustomDateParser); ok {
|
if i, ok := reader.(CustomDateParser); ok {
|
||||||
t, err := i.ParseDate(s)
|
t, err := i.ParseDate(s)
|
||||||
@ -77,7 +79,7 @@ func (ft FieldType) SqlFieldType() string {
|
|||||||
case Float:
|
case Float:
|
||||||
return "float"
|
return "float"
|
||||||
case Money:
|
case Money:
|
||||||
panic("do not implemented - see https://github.com/denisenkom/go-mssqldb/issues/460") // TODO: https://github.com/denisenkom/go-mssqldb/issues/460
|
return "numeric(15, 2)" // TODO: https://github.com/denisenkom/go-mssqldb/issues/460
|
||||||
case Date:
|
case Date:
|
||||||
return "date"
|
return "date"
|
||||||
case Timestamp:
|
case Timestamp:
|
||||||
|
@ -17,7 +17,7 @@ func TestCsvReaderBasic(t *testing.T) {
|
|||||||
encoding: "win1251",
|
encoding: "win1251",
|
||||||
comma: rune(";"[0]),
|
comma: rune(";"[0]),
|
||||||
skipRows: 3,
|
skipRows: 3,
|
||||||
fieldsTypes: "s ttffsssss",
|
fieldsTypes: "s ttmmsssss",
|
||||||
dateFormat: "02.01.2006",
|
dateFormat: "02.01.2006",
|
||||||
timestampFormat: "02.01.2006 15:04:05",
|
timestampFormat: "02.01.2006 15:04:05",
|
||||||
timezone: time.Local}
|
timezone: time.Local}
|
||||||
@ -34,7 +34,7 @@ func TestCsvReaderBasic(t *testing.T) {
|
|||||||
t2 := time.Date(2023, 03, 20, 0, 0, 0, 0, time.Local)
|
t2 := time.Date(2023, 03, 20, 0, 0, 0, 0, time.Local)
|
||||||
assert.Equal(t, []any{"307814009186", t1, t2, 499.00, 488.52, "522598******7141", "REZE64", "Покупка", "35068281112", "307817403283"}, row)
|
assert.Equal(t, []any{"307814009186", t1, t2, 499.00, 488.52, "522598******7141", "REZE64", "Покупка", "35068281112", "307817403283"}, row)
|
||||||
|
|
||||||
row, err = csvReader.GetRow(false)
|
_, err = csvReader.GetRow(false)
|
||||||
assert.Equal(t, err, io.EOF)
|
assert.Equal(t, err, io.EOF)
|
||||||
|
|
||||||
err = csvReader.Close()
|
err = csvReader.Close()
|
||||||
|
@ -14,7 +14,7 @@ func TestDbfReaderBasic(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
options := &Options{
|
options := &Options{
|
||||||
fieldsTypes: "sssssstdffsss",
|
fieldsTypes: "sssssstdmmsss",
|
||||||
timezone: time.Local,
|
timezone: time.Local,
|
||||||
encoding: "cp866"}
|
encoding: "cp866"}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ func TestDbfReaderBasic(t *testing.T) {
|
|||||||
t2 := time.Date(2023, 02, 21, 0, 0, 0, 0, time.Local)
|
t2 := time.Date(2023, 02, 21, 0, 0, 0, 0, time.Local)
|
||||||
assert.Equal(t, []any{"719089383780", "44", "8644", "570000009312", "STOLOVAYA TSPP", "844417", t1, t2, 1757.08, 1713.15, "536829XXXXXX9388", "UM1TS8", "D"}, row)
|
assert.Equal(t, []any{"719089383780", "44", "8644", "570000009312", "STOLOVAYA TSPP", "844417", t1, t2, 1757.08, 1713.15, "536829XXXXXX9388", "UM1TS8", "D"}, row)
|
||||||
|
|
||||||
row, err = dbfReader.GetRow(false)
|
_, err = dbfReader.GetRow(false)
|
||||||
assert.Equal(t, err, io.EOF)
|
assert.Equal(t, err, io.EOF)
|
||||||
|
|
||||||
err = dbfReader.Close()
|
err = dbfReader.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user