Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema support to Persistent (issue #93) #1561

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
f2f39a2
add new field and refactor away from entityDB
curranosaurus Sep 30, 2024
08a50bd
Merge pull request #1 from curranosaurus/curran/int-843
curranosaurus Sep 30, 2024
9c09206
add new field to construction
curranosaurus Sep 30, 2024
79eaa20
Merge branch 'master' of github.com:curranosaurus/persistent
curranosaurus Sep 30, 2024
1700101
prepend schema to entity db name
curranosaurus Sep 30, 2024
540c1b8
Merge pull request #2 from curranosaurus/curran/int-844
curranosaurus Sep 30, 2024
e07cae1
add schema test
curranosaurus Oct 1, 2024
6fea10e
remove redundant quotation marks
curranosaurus Oct 1, 2024
eb49123
revert
curranosaurus Oct 1, 2024
e0a7d27
create newtype for schema name
curranosaurus Oct 1, 2024
ea96742
add setters and getters
curranosaurus Oct 1, 2024
685f2cf
Merge pull request #3 from curranosaurus/curran/revert-change-to-getE…
curranosaurus Oct 1, 2024
009f7ab
Merge pull request #5 from curranosaurus/curran/create-setters-and-ge…
curranosaurus Oct 1, 2024
27e4ee7
suffix with DB
curranosaurus Oct 1, 2024
0c64924
Merge branch 'curran/update-entitySchema-to-its-own-newtype' of githu…
curranosaurus Oct 1, 2024
ab479e6
save wip
curranosaurus Oct 1, 2024
6048242
save wip
curranosaurus Oct 2, 2024
607bd67
Merge pull request #4 from curranosaurus/curran/update-entitySchema-t…
curranosaurus Oct 2, 2024
b079be2
add schema lookups to foreign key lookup
curranosaurus Oct 2, 2024
ce4eb39
add schema to information_schema query
curranosaurus Oct 2, 2024
1f8940d
change decisions about how to handle the public schema
curranosaurus Oct 2, 2024
4b37e1e
delete accidental hardcoding of foo schema
curranosaurus Oct 2, 2024
91f56b4
update migrater
curranosaurus Oct 2, 2024
799b58d
update sqlQQ test to consider a case with a schema
curranosaurus Oct 2, 2024
62ed272
strengthen test
curranosaurus Oct 2, 2024
320a9c1
Merge pull request #8 from curranosaurus/curran/update-sqlqq-to-injec…
curranosaurus Oct 3, 2024
b96c415
Merge pull request #7 from curranosaurus/curran/use-schema-in-postgre…
curranosaurus Oct 3, 2024
8fe5757
Merge pull request #6 from curranosaurus/curran/use-schema-in-postgre…
curranosaurus Oct 3, 2024
170450b
add schema to sqlite expressions
curranosaurus Oct 3, 2024
1ec4ca7
add schema test
curranosaurus Oct 3, 2024
309ce8b
set up migrations and queries for sqlite, improve test
curranosaurus Oct 3, 2024
5d0b4f0
include schema in qq parse
benjonesy Oct 2, 2024
e48552b
include schema name in foreign def
benjonesy Oct 3, 2024
6194a91
update quasi haddock
benjonesy Oct 3, 2024
b04da52
additional foreign schema test
benjonesy Oct 3, 2024
f3a0aa2
fix tests and migration code
curranosaurus Oct 3, 2024
d57084f
defer foreign reference schema definitions to TH
benjonesy Oct 3, 2024
3c3ca7b
Merge branch 'benj/include-schema-in-qq-parse' of github.com:curranos…
curranosaurus Oct 3, 2024
d098daa
add comment explaining limitation
curranosaurus Oct 3, 2024
ed1642b
remove TODO
curranosaurus Oct 3, 2024
708c0ed
consider the multi-db case
curranosaurus Oct 3, 2024
12eb34c
reverse a spot where we can't inject dot-qualified names
curranosaurus Oct 3, 2024
649c395
make test stronger
curranosaurus Oct 3, 2024
e4a0f27
Merge pull request #9 from curranosaurus/benj/include-schema-in-qq-parse
benjonesy Oct 4, 2024
6be1d6d
iterate tests and implementation
curranosaurus Oct 4, 2024
35c572d
Merge branch 'curran/sqlite-queries-use-schema' of github.com:currano…
curranosaurus Oct 7, 2024
b498d2a
Merge pull request #11 from curranosaurus/curran/second-pass-at-postgres
curranosaurus Oct 7, 2024
d0929f0
wip
benjonesy Oct 15, 2024
acef90f
wip
benjonesy Nov 20, 2024
096b82d
Merge branch 'master' into benj/mysql-schema-support
curranosaurus Dec 27, 2024
8a392d7
add test case, update mysql tests
curranosaurus Dec 27, 2024
2c70da8
fix migration test
curranosaurus Dec 27, 2024
a7dde4e
add schema to getColumn
curranosaurus Dec 30, 2024
c1570da
remove redundant import
curranosaurus Dec 30, 2024
6d1f9dd
Merge pull request #12 from curranosaurus/curran/mysql-schema-support
curranosaurus Dec 30, 2024
c0307bb
stop creating schema in postgres
curranosaurus Dec 30, 2024
4ea66ea
bump library version and document new api
curranosaurus Dec 30, 2024
cfafec6
bump persistent-mysql versions and add haddocks
curranosaurus Dec 30, 2024
1b068ae
bump versions in postgresql project
curranosaurus Dec 30, 2024
3bd72fd
bump version of sqlite package
curranosaurus Dec 30, 2024
8b6b752
bump persistent-test version
curranosaurus Dec 30, 2024
7f990da
add more haddock comments
curranosaurus Dec 30, 2024
65969ce
undo redundant change
curranosaurus Dec 30, 2024
a6598f3
update changelogs
curranosaurus Dec 30, 2024
e8c00d5
add more doc comments
curranosaurus Dec 30, 2024
755b9d2
run stylish-haskell
curranosaurus Dec 30, 2024
98b49bc
bump persistent-qq version
curranosaurus Dec 30, 2024
7bf74fc
account for null referenced schema name possibility
curranosaurus Dec 31, 2024
916cc4a
document a tricky use of a table-valued pragma
curranosaurus Dec 31, 2024
035075a
update postgres readme
curranosaurus Dec 31, 2024
a4e8af3
fix persistent-qq tests
curranosaurus Dec 31, 2024
e7efb53
use lowercase schema name
curranosaurus Dec 31, 2024
9b1aae0
add schema to checkForeignKeys query
curranosaurus Dec 31, 2024
896edc2
throw error if there is a cross-schema reference
curranosaurus Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions persistent-mysql/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for persistent-mysql

## 2.13.2

* [#1561](https://github.com/yesodweb/persistent/pull/1561)
* Add schema support to Persistent

## 2.13.1.5

* [#1526](https://github.com/yesodweb/persistent/pull/1526)
Expand Down
203 changes: 125 additions & 78 deletions persistent-mysql/Database/Persist/MySQL.hs

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions persistent-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ A backend for the `persistent` database library for the MySQL database server.
## Development

To run tests on this library, you will need to have a MySQL database server set up and running on your computer.
The test suite expects to see a database named `test` with a username `test` and password `test`. You can set this up with roughly as follows:
The test suite expects to see databases named `test` and `foo`, and a user with username `test` and password `test`. You can set this up with roughly as follows:

```
mysql -u root # MySQL root username and password may vary
CREATE DATABASE test;
CREATE DATABASE foo;
CREATE USER 'test'@'localhost' IDENTIFIED BY 'test';
GRANT ALL on test.* TO 'test'@'localhost';
```
GRANT ALL on foo.* TO 'test'@'localhost';
USE test;
```
8 changes: 4 additions & 4 deletions persistent-mysql/persistent-mysql.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent-mysql
version: 2.13.1.5
version: 2.13.2
license: MIT
license-file: LICENSE
author: Felipe Lessa <felipe.lessa@gmail.com>, Michael Snoyman
Expand Down Expand Up @@ -28,7 +28,7 @@ extra-source-files: ChangeLog.md

library
build-depends: base >= 4.9 && < 5
, persistent >= 2.13.3 && < 3
, persistent >= 2.14.7 && < 3
, aeson >= 1.0
, blaze-builder
, bytestring >= 0.10.8
Expand All @@ -54,15 +54,15 @@ test-suite test
type: exitcode-stdio-1.0
main-is: main.hs
hs-source-dirs: test
other-modules:
other-modules:
MyInit
InsertDuplicateUpdate
CustomConstraintTest
ImplicitUuidSpec
JSONTest
ghc-options: -Wall

build-depends:
build-depends:
base >= 4.9 && < 5
, aeson
, bytestring
Expand Down
5 changes: 4 additions & 1 deletion persistent-mysql/test/main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ import qualified MigrationOnlyTest
import qualified MigrationTest
import qualified MpsCustomPrefixTest
import qualified MpsNoPrefixTest
import qualified PersistUniqueTest
import qualified PersistentTest
import qualified PersistUniqueTest
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports sorted by stylish-haskell.

import qualified SchemaTest
import qualified TypeLitFieldDefsTest
-- FIXME: Not used... should it be?
-- import qualified PrimaryTest
Expand Down Expand Up @@ -149,6 +150,7 @@ main = do
, TransactionLevelTest.migration
-- , LongIdentifierTest.migration
, ForeignKey.compositeMigrate
, SchemaTest.migration
]
PersistentTest.cleanDB
ForeignKey.cleanDB
Expand Down Expand Up @@ -228,6 +230,7 @@ main = do
LongIdentifierTest.specsWith db
GeneratedColumnTestSQL.specsWith db
JSONTest.specs
SchemaTest.specsWith db

roundFn :: RealFrac a => a -> Integer
roundFn = round
Expand Down
4 changes: 3 additions & 1 deletion persistent-postgresql/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog for persistent-postgresql

## Unreleased
## 2.13.7

* [#1547](https://github.com/yesodweb/persistent/pull/1547)
* Bump `libpq` bounds
* [#1561](https://github.com/yesodweb/persistent/pull/1561)
* Add schema support to Persistent

## 2.13.6.2

Expand Down
Loading