{"id":31103692,"url":"https://github.com/oracle-samples/gorm-oracle","last_synced_at":"2026-02-17T18:00:48.130Z","repository":{"id":309572086,"uuid":"1034405470","full_name":"oracle-samples/gorm-oracle","owner":"oracle-samples","description":"The GORM Driver for Oracle brings full ORM support for Oracle Database to your Go applications","archived":false,"fork":false,"pushed_at":"2026-01-23T16:17:06.000Z","size":656,"stargazers_count":13,"open_issues_count":13,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-02-02T07:51:02.584Z","etag":null,"topics":["go","golang","gorm","oracle","orm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"upl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oracle-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-08T10:38:15.000Z","updated_at":"2026-01-03T13:54:26.000Z","dependencies_parsed_at":"2025-08-26T18:50:27.026Z","dependency_job_id":"854d31ae-d8b6-4ba8-86d4-eee34edab633","html_url":"https://github.com/oracle-samples/gorm-oracle","commit_stats":null,"previous_names":["oracle-samples/gorm-oracle"],"tags_count":4,"template":false,"template_full_name":"oracle/template-repo","purl":"pkg:github/oracle-samples/gorm-oracle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgorm-oracle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgorm-oracle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgorm-oracle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgorm-oracle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oracle-samples","download_url":"https://codeload.github.com/oracle-samples/gorm-oracle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgorm-oracle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29552224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T17:56:56.811Z","status":"ssl_error","status_checked_at":"2026-02-17T17:56:55.544Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","gorm","oracle","orm"],"created_at":"2025-09-17T02:50:08.059Z","updated_at":"2026-02-17T18:00:48.121Z","avatar_url":"https://github.com/oracle-samples.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GORM Driver for Oracle\n\nThe GORM Driver for Oracle provides support for Oracle Database, enabling full compatibility with GORM's ORM capabilities. It is built on top of the [Go Driver for Oracle (Godror)](https://github.com/godror/godror) and supports key features such as auto migrations, associations, transactions, and advanced querying.\n\n### Prerequisite: Install Instant Client\n\nTo use ODPI-C with Godror, you’ll need to install the Oracle Instant Client on your system. Follow the steps on [this page](https://odpi-c.readthedocs.io/en/latest/user_guide/installation.html) to complete the installation.\n\nAfter that, you can connect to the database using the `dataSourceName`, which specifies connection parameters (such as username and password) using a logfmt-encoded parameter list.\n\nThe way you specify the Instant Client directory differs by platform:\n\n- macOS and Windows: You can set the `libDir` parameter in the dataSourceName.\n- Linux: The libraries must be in the system library search path before your Go process starts, preferably configured with \"ldconfig\". The libDir parameter does not work on Linux.\n\n#### Example (macOS/Windows)\n\n``` go\ndataSourceName := `user=\"scott\" password=\"tiger\" \n                   connectString=\"dbhost:1521/orclpdb1\"\n                   libDir=\"/Path/to/your/instantclient_23_26\"`\n```\n\n#### Example (Linux)\n\n``` go\ndataSourceName := `user=\"scott\" password=\"tiger\" \n                   connectString=\"dbhost:1521/orclpdb1\"`\n```\n\n## Getting Started\n\n```go main.go\npackage main\n\nimport (\n  \"github.com/oracle-samples/gorm-oracle/oracle\"\n  \"gorm.io/gorm\"\n)\n\nfunc main() {\n  dataSourceName := `user=\"scott\" password=\"tiger\"\n                     connectString=\"dbhost:1521/orclpdb1\"`\n  db, err := gorm.Open(oracle.Open(dataSourceName), \u0026gorm.Config{})\n}\n```\n\n## Documentation\n\n### OnUpdate Foreign Key Constraint\n\nSince Oracle doesn’t support `ON UPDATE` in foreign keys, the driver simulates it using **triggers**.\n\nWhen a field has a constraint tagged with `OnUpdate`, the driver:\n\n1. Skips generating the unsupported `ON UPDATE` clause in the foreign key definition.\n2. Creates a trigger on the parent table that automatically cascades updates to the child table(s) whenever the referenced column is changed.\n\nThe `OnUpdate` tag accepts the following values (case-insensitive): `CASCADE`, `SET NULL`, and `SET DEFAULT`.\n\nTake the following struct for an example:\n\n```go\ntype Profile struct {\n  ID    uint\n  Name  string\n  Refer uint\n}\n\ntype Member struct {\n  ID        uint\n  Name      string\n  ProfileID uint\n  Profile   Profile `gorm:\"Constraint:OnUpdate:CASCADE\"`\n}\n```\n\nTrigger SQL created by the driver when migrating:\n\n```sql\nCREATE OR REPLACE TRIGGER \"fk_trigger_profiles_id_members_profile_id\"\nAFTER UPDATE OF \"id\" ON \"profiles\"\nFOR EACH ROW\nBEGIN\n  UPDATE \"members\"\n  SET \"profile_id\" = :NEW.\"id\"\n  WHERE \"profile_id\" = :OLD.\"id\";\nEND;\n```\n\n### JSON Columns\n\nUse either JSON type—both fully support `INSERT`, `UPDATE`, and `DELETE` … `RETURNING`:\n\n- `gorm.io/datatypes.JSON` — convenient for logging/printing; returned as text then rewrapped.\n- `encoding/json.RawMessage` — raw `[]byte` fast-path; ideal for large payloads or minimal decoding.\n\n#### Notes:\n- On multi-row `RETURNING`, we use PL/SQL bulk blocks and map results back into your structs.\n- `datatypes.JSON` comes back as text; `json.RawMessage` comes back as bytes.\n  \nTake the following struct as an example:\n\n```go\ntype Record struct {\n  ID         uint            `gorm:\"primaryKey;autoIncrement;column:record_id\"`\n  Name       string          `gorm:\"column:name\"`\n  // Text-oriented JSON\n  Properties datatypes.JSON  `gorm:\"column:properties\"`\n  // Raw bytes JSON\n  Payload    json.RawMessage `gorm:\"column:payload\"`\n}\n```\n\n## Contributing\n\nThis project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide](./CONTRIBUTING.md)\n\n## Security\n\nPlease consult the [security guide](./SECURITY.md) for our responsible security vulnerability disclosure process\n\n## License\n\nCopyright (c) 2025 Oracle and/or its affiliates. Released under the Universal Permissive License v1.0 as shown at \u003chttps://oss.oracle.com/licenses/upl/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-samples%2Fgorm-oracle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foracle-samples%2Fgorm-oracle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-samples%2Fgorm-oracle/lists"}