Skip to content

Commit aff1891

Browse files
committed
fix: Funnel step names cannot contain spaces
Fixes #359
1 parent f0844bb commit aff1891

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

packages/cubejs-schema-compiler/extensions/Funnels.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ ${eventJoin.join("\nLEFT JOIN\n")}
9999
}
100100

101101
eventsTableName(step) {
102-
return `${inflection.underscore(step.name)}_events`;
102+
return `${this.inflect(step)}_events`;
103103
}
104104

105105
stepUserIdColumnName(step) {
106-
return `${inflection.underscore(step.name)}_user_id`;
106+
return `${this.inflect(step)}_user_id`;
107+
}
108+
109+
inflect(step) {
110+
return inflection.underscore(inflection.camelize(step.name.replace(/[^A-Za-z0-9]+/g, '_')));
107111
}
108112

109113
stepSegmentSelect(funnelDefinition, step) {

packages/cubejs-schema-compiler/scaffolding/ScaffoldingTemplate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ScaffoldingTemplate {
9292
}
9393

9494
memberName(member) {
95-
return inflection.camelize(member.title.replace(/\s+|\./g, '_').toLowerCase(), true);
95+
return inflection.camelize(member.title.replace(/[^A-Za-z0-9]+/g, '_').toLowerCase(), true);
9696
}
9797

9898
renderFile(fileDescriptor) {

packages/cubejs-schema-compiler/test/ExtensionsTest.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ describe('Extensions', () => {
2323
},
2424
steps: [
2525
{
26-
name: 'application_installed',
26+
name: 'Application Installed',
2727
eventsTable: {
2828
sql: 'application_installed'
2929
}
3030
},
3131
{
32-
name: 'application_opened',
32+
name: 'ApplicationOpened',
3333
eventsView: {
3434
sql: 'application_opened'
3535
},
@@ -79,6 +79,10 @@ describe('Extensions', () => {
7979
});
8080

8181
console.log(query.buildSqlAndParams()[0]);
82+
83+
query.buildSqlAndParams()[0].should.match(/application_installed_events/);
84+
query.buildSqlAndParams()[0].should.match(/application_opened_events/);
85+
query.buildSqlAndParams()[0].should.match(/user_training_finish_first_events/);
8286
});
8387

8488
return result;

0 commit comments

Comments
 (0)