good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
upper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
open
upper
Commits
d9ac5ec9
Commit
d9ac5ec9
authored
May 26, 2015
by
Peter Kieltyka
Browse files
Options
Downloads
Patches
Plain Diff
Fix null values of wrapped types from being alloc'd
parent
989d3e1d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
util/sqlutil/fetch.go
+18
-9
18 additions, 9 deletions
util/sqlutil/fetch.go
with
18 additions
and
9 deletions
util/sqlutil/fetch.go
+
18
−
9
View file @
d9ac5ec9
...
@@ -152,7 +152,7 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
...
@@ -152,7 +152,7 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
values
:=
make
([]
interface
{},
len
(
columns
))
values
:=
make
([]
interface
{},
len
(
columns
))
typeMap
:=
rows
.
Mapper
.
TypeMap
(
itemT
)
typeMap
:=
rows
.
Mapper
.
TypeMap
(
itemT
)
fieldMap
:=
typeMap
.
Names
fieldMap
:=
typeMap
.
Names
wrappedValues
:=
map
[
reflect
.
Value
][
]
interface
{}{}
wrappedValues
:=
map
[
*
reflect
x
.
Field
]
interface
{}{}
for
i
,
k
:=
range
columns
{
for
i
,
k
:=
range
columns
{
fi
,
ok
:=
fieldMap
[
k
]
fi
,
ok
:=
fieldMap
[
k
]
...
@@ -161,19 +161,18 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
...
@@ -161,19 +161,18 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
continue
continue
}
}
f
:=
reflectx
.
FieldByIndexes
(
item
,
fi
.
Index
)
// TODO: refactor into a nice pattern
// TODO: refactor into a nice pattern
if
_
,
ok
:=
fi
.
Options
[
"stringarray"
];
ok
{
if
_
,
ok
:=
fi
.
Options
[
"stringarray"
];
ok
{
values
[
i
]
=
&
[]
byte
{}
values
[
i
]
=
&
[]
byte
{}
wrappedValues
[
f
]
=
[]
interface
{}{
"stringarray"
,
values
[
i
]
}
wrappedValues
[
f
i
]
=
values
[
i
]
}
else
if
_
,
ok
:=
fi
.
Options
[
"int64array"
];
ok
{
}
else
if
_
,
ok
:=
fi
.
Options
[
"int64array"
];
ok
{
values
[
i
]
=
&
[]
byte
{}
values
[
i
]
=
&
[]
byte
{}
wrappedValues
[
f
]
=
[]
interface
{}{
"int64array"
,
values
[
i
]
}
wrappedValues
[
f
i
]
=
values
[
i
]
}
else
if
_
,
ok
:=
fi
.
Options
[
"jsonb"
];
ok
{
}
else
if
_
,
ok
:=
fi
.
Options
[
"jsonb"
];
ok
{
values
[
i
]
=
&
[]
byte
{}
values
[
i
]
=
&
[]
byte
{}
wrappedValues
[
f
]
=
[]
interface
{}{
"jsonb"
,
values
[
i
]
}
wrappedValues
[
f
i
]
=
values
[
i
]
}
else
{
}
else
{
f
:=
reflectx
.
FieldByIndexes
(
item
,
fi
.
Index
)
values
[
i
]
=
f
.
Addr
()
.
Interface
()
values
[
i
]
=
f
.
Addr
()
.
Interface
()
}
}
...
@@ -194,9 +193,19 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
...
@@ -194,9 +193,19 @@ func fetchResult(itemT reflect.Type, rows *sqlx.Rows, columns []string) (reflect
}
}
// TODO: move this stuff out of here.. find a nice pattern
// TODO: move this stuff out of here.. find a nice pattern
for
f
,
v
:=
range
wrappedValues
{
for
fi
,
v
:=
range
wrappedValues
{
opt
:=
v
[
0
]
.
(
string
)
var
opt
string
b
:=
v
[
1
]
.
(
*
[]
byte
)
if
_
,
ok
:=
fi
.
Options
[
"stringarray"
];
ok
{
opt
=
"stringarray"
}
else
if
_
,
ok
:=
fi
.
Options
[
"int64array"
];
ok
{
opt
=
"int64array"
}
else
if
_
,
ok
:=
fi
.
Options
[
"jsonb"
];
ok
{
opt
=
"jsonb"
}
b
:=
v
.
(
*
[]
byte
)
f
:=
reflectx
.
FieldByIndexesReadOnly
(
item
,
fi
.
Index
)
switch
opt
{
switch
opt
{
case
"stringarray"
:
case
"stringarray"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment