Skip to content

Commit

Permalink
Use lowercase table names for better mariadb compat
Browse files Browse the repository at this point in the history
  • Loading branch information
ato committed Sep 21, 2023
1 parent e1e77e2 commit 340b38e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
32 changes: 16 additions & 16 deletions common/src/pandas/collection/CollectionRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ private static Map<Long, Long> toMap(List<TitleCount> list) {

@Query(value = """
with recursive cte1(COL_ID, ROOT_COL_ID, TITLE_COUNT) as (
select cs.COL_ID, cs.COL_ID, (select count(*) from TITLE_COL tc where tc.COLLECTION_ID = cs.COL_ID) as TITLE_COUNT
from COL_SUBS cs
select cs.COL_ID, cs.COL_ID, (select count(*) from title_col tc where tc.COLLECTION_ID = cs.COL_ID) as TITLE_COUNT
from col_subs cs
where cs.SUBJECT_ID = :subjectId
union all
select c.COL_ID, d.ROOT_COL_ID, (select count(*) from TITLE_COL tc where tc.COLLECTION_ID = c.COL_ID) as TITLE_COUNT
from COL c
select c.COL_ID, d.ROOT_COL_ID, (select count(*) from title_col tc where tc.COLLECTION_ID = c.COL_ID) as TITLE_COUNT
from col c
join cte1 d on c.COL_PARENT_ID = d.COL_ID)
select ROOT_COL_ID as id, SUM(TITLE_COUNT) as titleCount
from cte1
Expand All @@ -134,15 +134,15 @@ default Map<Long, Long> countTitlesForCollectionsInSubject(long subjectId) {

@Query(value = """
with recursive descendents2(COL_ID, ROOT_COL_ID) as
(select COL_ID, COL_ID from COL
(select COL_ID, COL_ID from col
where COL_PARENT_ID = :collectionId
union all
select c.COL_ID, d.ROOT_COL_ID
from COL c join descendents2 d on c.COL_PARENT_ID = d.COL_ID),
from col c join descendents2 d on c.COL_PARENT_ID = d.COL_ID),
descendent_counts2(COL_ID, ROOT_COL_ID, TITLE_COUNT) as
(select d.COL_ID,
d.ROOT_COL_ID,
(select count(*) from TITLE_COL tc where tc.COLLECTION_ID = d.COL_ID)
(select count(*) from title_col tc where tc.COLLECTION_ID = d.COL_ID)
from descendents2 d)
select ROOT_COL_ID as id, sum(TITLE_COUNT) as titleCount
from descendent_counts2
Expand All @@ -159,15 +159,15 @@ default Map<Long, Long> countTitlesForChildCollections(long collectionId) {

@Query(value = """
with recursive descendents3(COL_ID, ROOT_COL_ID) as
(select COL_ID, COL_ID from COL
(select COL_ID, COL_ID from col
where COL_ID in :collectionIds
union all
select c.COL_ID, d.ROOT_COL_ID
from COL c join descendents3 d on c.COL_PARENT_ID = d.COL_ID),
from col c join descendents3 d on c.COL_PARENT_ID = d.COL_ID),
descendent_counts3(COL_ID, ROOT_COL_ID, TITLE_COUNT) as
(select d.COL_ID,
d.ROOT_COL_ID,
(select count(*) from TITLE_COL tc where tc.COLLECTION_ID = d.COL_ID)
(select count(*) from title_col tc where tc.COLLECTION_ID = d.COL_ID)
from descendents3 d)
select ROOT_COL_ID as id, sum(TITLE_COUNT) as titleCount
from descendent_counts3
Expand Down Expand Up @@ -199,17 +199,17 @@ default String line2() {

@Query(value = """
with recursive descendents1(COL_ID, ROOT_COL_ID, START_DATE, END_DATE) as
(select COL_ID, COL_ID, START_DATE, END_DATE from COL
(select COL_ID, COL_ID, START_DATE, END_DATE from col
where COL_ID = :collectionId
union all
select c.COL_ID, d.ROOT_COL_ID, COALESCE(c.START_DATE, d.START_DATE), COALESCE(c.END_DATE, d.END_DATE)
from COL c
from col c
join descendents1 d on c.COL_PARENT_ID = d.COL_ID),
instanceIds(INSTANCE_ID) as
(select distinct i.INSTANCE_ID
from descendents1 d
join TITLE_COL tc on tc.COLLECTION_ID = d.COL_ID
join INSTANCE i on tc.TITLE_ID = i.TITLE_ID
join title_col tc on tc.COLLECTION_ID = d.COL_ID
join instance i on tc.TITLE_ID = i.TITLE_ID
where i.CURRENT_STATE_ID = 1
and (d.START_DATE is null or i.INSTANCE_DATE >= d.START_DATE)
and (d.END_DATE is null or i.INSTANCE_DATE <= d.END_DATE))
Expand All @@ -218,8 +218,8 @@ select coalesce(count(distinct i.TITLE_ID), 0) as titleCount,
coalesce(sum(ig.GATHER_SIZE), 0) as gatheredBytes,
coalesce(sum(ig.GATHER_FILES), 0) as gatheredFiles
from instanceIds i2
join INSTANCE i on i.INSTANCE_ID = i2.INSTANCE_ID
join INS_GATHER ig on i.INSTANCE_ID = ig.INSTANCE_ID""",
join instance i on i.INSTANCE_ID = i2.INSTANCE_ID
join ins_gather ig on i.INSTANCE_ID = ig.INSTANCE_ID""",
nativeQuery = true, queryRewriter = WithRecursiveQueryRewriter.class)
CollectionStats calculateCollectionStats(long collectionId);
}
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
MARIADB_DATABASE: pandas3
MARIADB_USER: pandas3
MARIADB_PASSWORD: pandas3
command: --lower-case-table-names=1

ui:
build:
Expand Down

0 comments on commit 340b38e

Please sign in to comment.