Skip to content

Commit 69b0a28

Browse files
authored
chore: data model style updates (#6644)
* chore: data model style updates * fixes
1 parent 8057034 commit 69b0a28

File tree

3 files changed

+193
-197
lines changed

3 files changed

+193
-197
lines changed

packages/cubejs-cli/src/templates.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ const ordersJs = `cube(\`orders\`, {
218218
\`,
219219
220220
pre_aggregations: {
221-
// Pre-aggregation definitions go here
222-
// Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
221+
// Pre-aggregation definitions go here.
222+
// Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started
223223
},
224224
225225
measures: {
@@ -287,8 +287,8 @@ const ordersYml = `cubes:
287287
UNION ALL
288288
SELECT 5 AS id, 600 AS amount, 'shipped' status
289289
290-
# Pre-aggregation definitions go here
291-
# Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
290+
# Pre-aggregation definitions go here.
291+
# Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started
292292
# pre_aggregations:
293293
294294
measures:

packages/cubejs-schema-compiler/src/scaffolding/formatters/BaseSchemaFormatter.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ export abstract class BaseSchemaFormatter {
127127
...sqlOption,
128128
...dataSourceProp,
129129

130-
[this.options.snakeCase ? 'pre_aggregations' : 'preAggregations']: new ValueWithComments(
131-
null,
132-
[
133-
'Pre-aggregation definitions go here',
134-
'Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started',
135-
]
136-
),
137130
joins: tableSchema.joins
138131
.map((j) => ({
139132
[j.cubeToJoin]: {
@@ -146,36 +139,45 @@ export abstract class BaseSchemaFormatter {
146139
},
147140
}))
148141
.reduce((a, b) => ({ ...a, ...b }), {}),
149-
measures: tableSchema.measures
142+
dimensions: tableSchema.dimensions
150143
.map((m) => ({
151144
[this.memberName(m)]: {
152145
sql: this.sqlForMember(m),
153146
type: m.type ?? m.types[0],
154147
title: this.memberTitle(m),
148+
[this.options.snakeCase ? 'primary_key' : 'primaryKey']: m.isPrimaryKey
149+
? true
150+
: undefined,
155151
},
156152
}))
157-
.reduce((a, b) => ({ ...a, ...b }), {
158-
count: {
159-
type: 'count',
160-
},
161-
}),
162-
dimensions: tableSchema.dimensions
153+
.reduce((a, b) => ({ ...a, ...b }), {}),
154+
measures: tableSchema.measures
163155
.map((m) => ({
164156
[this.memberName(m)]: {
165157
sql: this.sqlForMember(m),
166158
type: m.type ?? m.types[0],
167159
title: this.memberTitle(m),
168-
[this.options.snakeCase ? 'primary_key' : 'primaryKey']: m.isPrimaryKey
169-
? true
170-
: undefined,
171160
},
172161
}))
173-
.reduce((a, b) => ({ ...a, ...b }), {}),
162+
.reduce((a, b) => ({ ...a, ...b }), {
163+
count: {
164+
type: 'count',
165+
},
166+
}),
167+
174168
...(this.options.snakeCase
175169
? Object.fromEntries(
176170
Object.entries(contextProps).map(([key, value]) => [toSnakeCase(key), value])
177171
)
178172
: contextProps),
173+
174+
[this.options.snakeCase ? 'pre_aggregations' : 'preAggregations']: new ValueWithComments(
175+
null,
176+
[
177+
'Pre-aggregation definitions go here.',
178+
'Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started',
179+
]
180+
),
179181
};
180182
}
181183

0 commit comments

Comments
 (0)