mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
This pull request significantly improves PostgreSQL array type handling and conversion in the `pgsql` driver, providing more accurate type mapping and conversion logic, especially for array types. It introduces comprehensive documentation, refactors conversion logic to use the `pq` package for array types, and adds extensive unit tests to ensure correctness and error handling. Additionally, minor enhancements and clarifications are made to upsert formatting and table field queries. ### PostgreSQL Array Type Handling and Conversion * Refactored `CheckLocalTypeForField` and `ConvertValueForLocal` methods in `contrib/drivers/pgsql/pgsql_convert.go` to accurately map PostgreSQL array types (such as `_int2`, `_int4`, `_int8`, `_float4`, `_float8`, `_bool`, `_varchar`, `_text`, `_char`, `_bpchar`, `_numeric`, `_decimal`, `_money`, `_bytea`) to their corresponding Go types, using the `pq` package for conversion. Added detailed documentation and mapping tables for supported types. [[1]](diffhunk://#diff-a3b1e68bfa29fbcfda7c703bbe875fa82e958f6c3ad942ef82193a9dd8ad67e2R46-R63) [[2]](diffhunk://#diff-a3b1e68bfa29fbcfda7c703bbe875fa82e958f6c3ad942ef82193a9dd8ad67e2L56-R103) [[3]](diffhunk://#diff-a3b1e68bfa29fbcfda7c703bbe875fa82e958f6c3ad942ef82193a9dd8ad67e2R112-R209) * Added comprehensive unit tests in `contrib/drivers/pgsql/pgsql_z_unit_convert_test.go` to verify type mapping and conversion for all supported array types, including error cases for invalid input. ### Utility and API Improvements * Added a new `Bools()` method to the `gvar.Var` type in `container/gvar/gvar_slice.go` for converting values to `[]bool`, with corresponding unit tests in `container/gvar/gvar_z_unit_slice_test.go`. [[1]](diffhunk://#diff-32e887e540e0170f785508d105cb794e4d54d854b53b6950973c80022973c490R11-R15) [[2]](diffhunk://#diff-01453eca4d4b3e35d07ca105cb924c6441d0cd9df6cbcc337a89832c8d53057fR24-R41) ### SQL Formatting and Documentation * Improved documentation and formatting in the upsert logic of `contrib/drivers/pgsql/pgsql_format_upsert.go` to clarify the use of `EXCLUDED` in PostgreSQL's `ON CONFLICT DO UPDATE`. * Enhanced readability of the table field query in `contrib/drivers/pgsql/pgsql_table_fields.go` by reformatting SQL and clarifying field extraction. --------- Co-authored-by: hailaz <739476267@qq.com> Co-authored-by: houseme <housemecn@gmail.com>
41 lines
1.4 KiB
Modula-2
41 lines
1.4 KiB
Modula-2
module github.com/gogf/gf/contrib/drivers/pgsql/v2
|
|
|
|
go 1.23.0
|
|
|
|
require (
|
|
github.com/gogf/gf/v2 v2.9.6
|
|
github.com/google/uuid v1.6.0
|
|
github.com/lib/pq v1.10.9
|
|
)
|
|
|
|
require (
|
|
github.com/BurntSushi/toml v1.5.0 // indirect
|
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
|
github.com/emirpasic/gods/v2 v2.0.0-alpha // indirect
|
|
github.com/fatih/color v1.18.0 // indirect
|
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
|
github.com/go-logr/logr v1.4.3 // indirect
|
|
github.com/go-logr/stdr v1.2.2 // indirect
|
|
github.com/gorilla/websocket v1.5.3 // indirect
|
|
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
|
github.com/magiconair/properties v1.8.10 // indirect
|
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
|
github.com/olekukonko/errors v1.1.0 // indirect
|
|
github.com/olekukonko/ll v0.0.9 // indirect
|
|
github.com/olekukonko/tablewriter v1.1.0 // indirect
|
|
github.com/rivo/uniseg v0.2.0 // indirect
|
|
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
|
go.opentelemetry.io/otel v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
|
golang.org/x/net v0.40.0 // indirect
|
|
golang.org/x/sys v0.35.0 // indirect
|
|
golang.org/x/text v0.25.0 // indirect
|
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
)
|
|
|
|
replace github.com/gogf/gf/v2 => ../../../
|