mirror of https://github.com/go-gorm/gorm.git
c063624c91
gorm.Errors, which usefully implements `error` for an `[]error` as returned by `DB.GetError()` was already exported, but because it used a private field `errors`, it was not able to be created due to the compile-time error: implicit assignment of unexported field 'errors' in gorm.Errors literal The trivial solution would be to export the `errors` field on `gorm.Errors`, but this led to the issue that the common pattern of checking `err != nil` failed because a struct{error: nil} != nil. We can take advantage of type aliasing here to make Errors an []error, which can in fact be nil and would pass `err != nil` on the happy path. * Remove `(Errors) GetErrors()`, as it's less useful when Errors is an []error which can be iterated over. While this is technically a breaking change, we never expose an Errors and its difficult to build one (it can be done with the existing `(Errors) Add(error)`), but awkwardly. This removal can be reverted without issue and we can make it an identity method, but it seemed an opportune time to reduce API surface area on something that likely isn't used. * Remove errorsInterface, as it's not useful without `(Errors) GetErrors()` * Change `(*Errors) Add(error)` => `(Errors) Add(error...) Errors` because we can't modify even a *Errors when it's a type alias. This is more idiomatic as it follows the pattern of `slice = append(slice, element)` Go developers are familiar with. |
||
---|---|---|
dialects | ||
.codeclimate.yml | ||
.gitignore | ||
CONTRIBUTING.md | ||
License | ||
README.md | ||
association.go | ||
association_test.go | ||
callback.go | ||
callback_create.go | ||
callback_delete.go | ||
callback_query.go | ||
callback_query_preload.go | ||
callback_save.go | ||
callback_system_test.go | ||
callback_update.go | ||
callbacks_test.go | ||
create_test.go | ||
customize_column_test.go | ||
delete_test.go | ||
dialect.go | ||
dialect_common.go | ||
dialect_mysql.go | ||
dialect_postgres.go | ||
dialect_sqlite3.go | ||
embedded_struct_test.go | ||
errors.go | ||
errors_test.go | ||
field.go | ||
field_test.go | ||
interface.go | ||
join_table_handler.go | ||
join_table_test.go | ||
logger.go | ||
main.go | ||
main_test.go | ||
migration_test.go | ||
model.go | ||
model_struct.go | ||
multi_primary_keys_test.go | ||
pointer_test.go | ||
polymorphic_test.go | ||
preload_test.go | ||
query_test.go | ||
scaner_test.go | ||
scope.go | ||
scope_test.go | ||
search.go | ||
search_test.go | ||
test_all.sh | ||
update_test.go | ||
utils.go | ||
utils_test.go | ||
wercker.yml |
README.md
GORM
The fantastic ORM library for Golang, aims to be developer friendly.
Overview
- Full-Featured ORM (almost)
- Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)
- Callbacks (Before/After Create/Save/Update/Delete/Find)
- Preloading (eager loading)
- Transactions
- Composite Primary Key
- SQL Builder
- Auto Migrations
- Logger
- Extendable, write Plugins based on GORM callbacks
- Every feature comes with tests
- Developer Friendly
Getting Started
- GORM Guides jinzhu.github.com/gorm
Upgrading To V1.0
Author
jinzhu
Contributors
https://github.com/jinzhu/gorm/graphs/contributors
License
Released under the MIT License.