Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
e2522f4f
Unverified
Commit
e2522f4f
authored
4 months ago
by
metamben
Committed by
GitHub
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix model conversion (#50215)
parent
5be95100
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+49
-0
49 additions, 0 deletions
...enarios/question-reproductions/reproductions-3.cy.spec.js
frontend/src/metabase/query_builder/actions/models.ts
+8
-37
8 additions, 37 deletions
frontend/src/metabase/query_builder/actions/models.ts
with
57 additions
and
37 deletions
e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+
49
−
0
View file @
e2522f4f
...
...
@@ -28,6 +28,7 @@ import {
openNotebook
,
openOrdersTable
,
openProductsTable
,
openQuestionActions
,
openTable
,
popover
,
queryBuilderFooter
,
...
...
@@ -2436,3 +2437,51 @@ describe("issue 50038", () => {
});
});
});
describe
(
"
issue 47940
"
,
()
=>
{
const
questionDetails
=
{
name
:
"
Issue 47940
"
,
query
:
{
"
source-table
"
:
ORDERS_ID
,
limit
:
5
,
},
};
beforeEach
(()
=>
{
restore
();
cy
.
signInAsAdmin
();
cy
.
intercept
(
"
PUT
"
,
"
/api/card/*
"
).
as
(
"
updateCard
"
);
cy
.
intercept
(
"
POST
"
,
"
/api/card/*/query
"
).
as
(
"
cardQuery
"
);
});
it
(
"
should be able to convert a question with date casting to a model
"
,
()
=>
{
cy
.
log
(
"
create a question without any column casting
"
);
createQuestion
(
questionDetails
,
{
visitQuestion
:
true
});
cy
.
wait
(
"
@cardQuery
"
);
cy
.
log
(
"
add coercion
"
);
cy
.
request
(
"
PUT
"
,
`/api/field/
${
ORDERS
.
PRODUCT_ID
}
`
,
{
semantic_type
:
"
type/Category
"
,
coercion_strategy
:
"
Coercion/UNIXMicroSeconds->DateTime
"
,
});
cy
.
log
(
"
get new query results with coercion applied
"
);
queryBuilderHeader
().
findByTestId
(
"
run-button
"
).
click
();
cy
.
wait
(
"
@cardQuery
"
);
queryBuilderHeader
().
button
(
"
Save
"
).
click
();
modal
().
button
(
"
Save
"
).
click
();
cy
.
wait
(
"
@updateCard
"
);
cy
.
log
(
"
turn into a model
"
);
openQuestionActions
();
popover
().
findByText
(
"
Turn into a model
"
).
click
();
cy
.
findByRole
(
"
dialog
"
).
findByText
(
"
Turn this into a model
"
).
click
();
cy
.
wait
(
"
@updateCard
"
);
cy
.
log
(
"
verify there is a table displayed
"
);
cy
.
findByTestId
(
"
visualization-root
"
).
should
(
"
contain
"
,
"
December 31, 1969, 4:00 PM
"
,
);
});
});
This diff is collapsed.
Click to expand it.
frontend/src/metabase/query_builder/actions/models.ts
+
8
−
37
View file @
e2522f4f
...
...
@@ -2,16 +2,13 @@ import { push } from "react-router-redux";
import
{
createAction
}
from
"
redux-actions
"
;
import
{
t
}
from
"
ttag
"
;
import
Questions
from
"
metabase/entities/questions
"
;
import
{
loadMetadataForCard
}
from
"
metabase/questions/actions
"
;
import
{
addUndo
}
from
"
metabase/redux/undo
"
;
import
{
getMetadata
}
from
"
metabase/selectors/metadata
"
;
import
type
{
Dispatch
,
GetState
}
from
"
metabase-types/store
"
;
import
{
getQuestion
}
from
"
../selectors
"
;
import
{
API_UPDATE_QUESTION
,
apiUpdateQuestion
,
updateQuestion
}
from
"
./core
"
;
import
{
runDirtyQuestionQuery
,
runQuestionQuery
}
from
"
./querying
"
;
import
{
apiUpdateQuestion
,
updateQuestion
}
from
"
./core
"
;
import
{
runDirtyQuestionQuery
}
from
"
./querying
"
;
import
{
setQueryBuilderMode
}
from
"
./ui
"
;
export
const
setDatasetEditorTab
=
...
...
@@ -29,41 +26,16 @@ export const onCancelCreateNewModel = () => async (dispatch: Dispatch) => {
export
const
turnQuestionIntoModel
=
()
=>
async
(
dispatch
:
Dispatch
,
getState
:
GetState
)
=>
{
const
question
=
getQuestion
(
getState
());
if
(
!
question
)
{
return
;
}
await
dispatch
(
Questions
.
actions
.
update
(
{
id
:
question
.
id
(),
},
question
.
setType
(
"
model
"
)
.
setPinned
(
true
)
.
setDisplay
(
"
table
"
)
.
setSettings
({})
.
card
(),
),
);
const
metadata
=
getMetadata
(
getState
());
const
dataset
=
metadata
.
question
(
question
.
id
());
if
(
!
dataset
)
{
return
;
}
await
dispatch
(
loadMetadataForCard
(
dataset
.
card
()));
await
dispatch
({
type
:
API_UPDATE_QUESTION
,
payload
:
dataset
.
card
()
});
await
dispatch
(
runQuestionQuery
({
shouldUpdateUrl
:
true
,
}),
);
const
model
=
question
.
setType
(
"
model
"
)
.
setPinned
(
true
)
.
setDisplay
(
"
table
"
)
.
setSettings
({});
await
dispatch
(
apiUpdateQuestion
(
model
,
{
rerunQuery
:
true
}));
dispatch
(
addUndo
({
...
...
@@ -76,7 +48,6 @@ export const turnQuestionIntoModel =
export
const
turnModelIntoQuestion
=
()
=>
async
(
dispatch
:
Dispatch
,
getState
:
GetState
)
=>
{
const
model
=
getQuestion
(
getState
());
if
(
!
model
)
{
return
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment