The fantastic ORM library for Golang, aims to be developer friendly
Go to file
Caleb Thompson c063624c91
Make gorm.Errors available for use outside gorm
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.
2016-10-25 11:22:50 -05:00
dialects Expose current database name API 2016-07-11 21:37:44 +08:00
.codeclimate.yml Add codeclimate 2015-08-22 08:46:46 +08:00
.gitignore Update README 2016-02-29 22:06:15 +08:00
CONTRIBUTING.md Update CONTRIBUTING.md executable script template 2016-09-20 16:55:01 +01:00
License Add MIT License file 2015-01-05 08:59:18 +08:00
README.md Update README 2016-05-04 21:13:24 +08:00
association.go Fix Replace has one/many associations 2016-10-20 13:27:26 +08:00
association_test.go Fix Replace has one/many associations 2016-10-20 13:27:26 +08:00
callback.go Fix GORM with Go 1.4 #892 2016-03-09 20:44:31 +08:00
callback_create.go Set PrimaryField IsBlank to false after read from returning value 2016-09-13 08:24:29 +08:00
callback_delete.go Set identity insert on after create transaction, close #841 2016-03-05 19:22:33 +08:00
callback_query.go Fix scan columns with same name 2016-03-10 17:13:48 +08:00
callback_query_preload.go Merge pull request #1199 from jugglinmike/empty-associations 2016-10-06 21:23:04 +08:00
callback_save.go Refactor named value support for PolymorphicType 2016-10-06 20:33:48 +08:00
callback_system_test.go Rename test files 2016-03-08 22:00:15 +08:00
callback_update.go Refactor Scope updatedAttrsWithValues 2016-03-09 16:45:53 +08:00
callbacks_test.go update tests 2014-08-28 16:14:44 +08:00
create_test.go Fix null time not allowed in mysql5.7 test error 2016-10-19 12:20:45 +08:00
customize_column_test.go Fix null time not allowed in mysql5.7 test error 2016-10-19 12:20:45 +08:00
delete_test.go DeletedAt's type has to been *time.Time 2016-01-10 21:38:10 +08:00
dialect.go Expose current database name API 2016-07-11 21:37:44 +08:00
dialect_common.go Expose current database name API 2016-07-11 21:37:44 +08:00
dialect_mysql.go Expose current database name API 2016-07-11 21:37:44 +08:00
dialect_postgres.go Expose current database name API 2016-07-11 21:37:44 +08:00
dialect_sqlite3.go Expose current database name API 2016-07-11 21:37:44 +08:00
embedded_struct_test.go Support set prefix for embedded struct 2016-09-05 22:26:57 +08:00
errors.go Make gorm.Errors available for use outside gorm 2016-10-25 11:22:50 -05:00
errors_test.go Make gorm.Errors available for use outside gorm 2016-10-25 11:22:50 -05:00
field.go Print warning message when using unaddressable value with Update 2016-04-04 21:33:11 +08:00
field_test.go scope.Fields() return slice of *Field 2016-03-07 14:25:41 +08:00
interface.go
join_table_handler.go Refactor based on golint 2016-03-07 17:49:55 +08:00
join_table_test.go Merge branch 'master' into v1.0_dev 2016-01-12 15:47:50 +08:00
logger.go Export LogWriter interface 2016-03-10 17:38:52 +08:00
main.go Make gorm.Errors available for use outside gorm 2016-10-25 11:22:50 -05:00
main_test.go Merge pull request #1210 from baijum/error-zero-args 2016-10-23 22:58:23 +08:00
migration_test.go Fix Replace has one/many associations 2016-10-20 13:27:26 +08:00
model.go Rename test files 2016-03-08 22:00:15 +08:00
model_struct.go Refactor named value support for PolymorphicType 2016-10-06 20:33:48 +08:00
multi_primary_keys_test.go Fix some go vet/lint reports 2016-01-15 21:16:48 +08:00
pointer_test.go Fix some go vet/lint reports 2016-01-15 21:16:48 +08:00
polymorphic_test.go Refactor named value support for PolymorphicType 2016-10-06 20:33:48 +08:00
preload_test.go Return empty slice for associations with 0 results 2016-09-27 17:09:57 -04:00
query_test.go Fix null time not allowed in mysql5.7 test error 2016-10-19 12:20:45 +08:00
scaner_test.go Fix broken tests for postgres 2016-06-24 07:48:03 +08:00
scope.go Refactor named value support for PolymorphicType 2016-10-07 22:19:28 +08:00
scope_test.go Add support for signed and unsigned integer types as primary key type 2014-10-22 17:33:13 +02:00
search.go Add ORDER BY sql expression support 2016-06-28 11:15:42 +08:00
search_test.go Add SelectAttrs, OmitAttrs 2015-03-12 15:50:38 +08:00
test_all.sh Remove foundationdb from tests all script because it is not downloadable from offical site 2015-04-17 14:52:59 +08:00
update_test.go Fix TestUpdateDecodeVirtualAttributes 2016-08-14 16:13:50 +08:00
utils.go Fixing go get error 2016-07-16 14:14:46 +01:00
utils_test.go Add CHANGELOG 2016-02-20 23:34:33 +08:00
wercker.yml Add wercker.yml with postgres and mysql tests 2016-05-22 01:59:25 +02:00

README.md

GORM

The fantastic ORM library for Golang, aims to be developer friendly.

Join the chat at https://gitter.im/jinzhu/gorm wercker status GoDoc

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

Upgrading To V1.0

Author

jinzhu

Contributors

https://github.com/jinzhu/gorm/graphs/contributors

License

Released under the MIT License.