MCPcopy Create free account
hub / github.com/actiontech/dtle / UnitstrConvert

Function UnitstrConvert

driver/oracle/extractor/sql_parse.go:198–220  ·  view source on GitHub ↗
(data string)

Source from the content-addressed store, hash-verified

196}
197
198func UnitstrConvert(data string) string {
199 if data == "" {
200 return data
201 }
202 // no unit case
203 // Multiple UNISTR function calls maybe concatenated together using "||".
204 // We split the values into their respective parts before parsing each one separately.
205 regex, err := regexp.Compile(CONCATENATIONPATTERN)
206 if err != nil {
207 return ""
208 }
209 parts := regex.Split(data, -1)
210 results := make([]string, len(parts))
211 for i := range parts {
212 trimPart := strings.TrimSpace(parts[i])
213 if isUnistrFunction(trimPart) {
214 results = append(results, UnitstrDecode(trimPart[7:len(trimPart)-1]))
215 } else {
216 results = append(results, data)
217 }
218 }
219 return strings.Join(results, "")
220}
221
222func UnitstrDecode(value string) string {
223 strconv.ParseInt(value, 10, 16)

Callers 1

columnsValueConverterFunction · 0.85

Calls 2

isUnistrFunctionFunction · 0.85
UnitstrDecodeFunction · 0.85

Tested by

no test coverage detected