diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index fad00ba748b0..9d22f07a08c8 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,6 +1,6 @@ name: Bug report description: Report a bug to improve Superset's stability -labels: ["bug"] +labels: ["#bug"] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/cosmetic.md b/.github/ISSUE_TEMPLATE/cosmetic.md index 1a2e6ea2da02..c5d23121db31 100644 --- a/.github/ISSUE_TEMPLATE/cosmetic.md +++ b/.github/ISSUE_TEMPLATE/cosmetic.md @@ -1,7 +1,7 @@ --- name: Cosmetic Issue about: Describe a cosmetic issue with CSS, positioning, layout, labeling, or similar -labels: "cosmetic-issue" +labels: "#bug:cosmetic" --- ## Screenshot diff --git a/scripts/benchmark_migration.py b/scripts/benchmark_migration.py index 6da1386e1cd4..550d3fda4181 100644 --- a/scripts/benchmark_migration.py +++ b/scripts/benchmark_migration.py @@ -93,7 +93,7 @@ def find_models(module: ModuleType) -> list[type[Model]]: # noqa: C901 # where the current model is out-of-sync with the existing table after a # downgrade sqlalchemy_uri = current_app.config["SQLALCHEMY_DATABASE_URI"] - engine = create_engine(sqlalchemy_uri, future=True) + engine = create_engine(sqlalchemy_uri) Base = automap_base() # noqa: N806 Base.prepare(engine, reflect=True) seen = set() diff --git a/superset-frontend/playwright/tests/recently-archived/delete-modal.spec.ts b/superset-frontend/playwright/tests/recently-archived/delete-modal.spec.ts deleted file mode 100644 index 74a828bb2aa4..000000000000 --- a/superset-frontend/playwright/tests/recently-archived/delete-modal.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * With SOFT_DELETE enabled the delete-confirmation modal becomes recoverable: - * it explains the object is moved to the archive (and for how long), and drops - * the "type DELETE to confirm" friction. Non-destructive — the modal is opened - * and dismissed without deleting anything. - */ -import { test, expect } from '@playwright/test'; -import { skipUnlessFeatureEnabled } from '../../helpers/featureFlags'; - -test.beforeEach(async ({ page }) => { - await skipUnlessFeatureEnabled(page, 'SOFT_DELETE'); -}); - -test('chart delete confirmation reflects soft-delete (archive) semantics', async ({ - page, -}) => { - await page.goto('chart/list/'); - await page.locator('[data-test="chart-row-delete"]').first().waitFor(); - await page.locator('[data-test="chart-row-delete"]').first().click(); - - // The action reads as "Archive", not "Delete". Scope to the dialog: with - // the flag on, every list row's delete action is also named "Archive", so - // an unscoped button query is a strict-mode violation (25 rows + modal). - const dialog = page.getByRole('dialog'); - await expect(dialog.getByText(/^Archive .+\?$/)).toBeVisible(); - await expect(dialog.getByRole('button', { name: 'Archive' })).toBeVisible(); - - // Recoverable copy instead of "Are you sure … permanently". - await expect(page.getByText(/moved to Recently Archived/i)).toBeVisible(); - await expect( - page.getByText(/recover it there within \d+ days/i), - ).toBeVisible(); - - // No "type DELETE to confirm" input in recoverable mode. - await expect(page.getByTestId('delete-modal-input')).toHaveCount(0); - - // Dismiss without deleting. - await page.getByTestId('close-modal-btn').click(); -}); diff --git a/superset-frontend/playwright/tests/recently-archived/recently-archived.spec.ts b/superset-frontend/playwright/tests/recently-archived/recently-archived.spec.ts index ff9721ae7cf8..60be53708f78 100644 --- a/superset-frontend/playwright/tests/recently-archived/recently-archived.spec.ts +++ b/superset-frontend/playwright/tests/recently-archived/recently-archived.spec.ts @@ -29,7 +29,7 @@ * restore it and asserts — via the API — that it is live again. */ import { test, expect, Page } from '@playwright/test'; -import { apiGet, apiPost } from '../../helpers/api/requests'; +import { apiGet } from '../../helpers/api/requests'; import { extractIdFromResponse } from '../../helpers/api/assertions'; import { apiPostChart, @@ -188,58 +188,3 @@ test('permanently deletes an archived item from the view', async ({ page }) => { await TYPES[0].softDelete(page, id).catch(() => {}); } }); - -test('shows an empty message and no rows when the search matches nothing', async ({ - page, -}) => { - await page.goto('archived/'); - await expect(page.getByTestId('archived-list-view')).toBeVisible(); - - const search = page.getByPlaceholder(/type a value/i); - await search.click(); - await search.fill(`e2e_nonexistent_${Date.now()}`); - await search.press('Enter'); - - await expect( - page.getByText('No results match your filter criteria'), - ).toBeVisible(); - await expect(page.getByTestId('archived-row-restore')).toHaveCount(0); -}); - -test('restoring an already-restored row surfaces an error without crashing', async ({ - page, -}) => { - const name = `e2e_stale_${Date.now()}`; - const id = await TYPES[0].create(page, name); - // Capture the uuid before soft-delete (a soft-deleted GET returns 404). - const { uuid } = (await (await apiGetDashboard(page, id)).json()).result; - try { - expect((await apiDeleteDashboard(page, id)).ok()).toBeTruthy(); - - await openArchive(page, 'Dashboard', name); - await expect(page.getByText(name, { exact: false })).toBeVisible(); - - // Simulate another actor restoring the object out from under this view. - const restored = await apiPost( - page, - `api/v1/dashboard/${uuid}/restore`, - {}, - ); - expect(restored.ok()).toBeTruthy(); - - // Clicking the now-stale row's Restore yields a 404 → danger toast, no crash. - await page - .getByRole('row') - .filter({ hasText: name }) - .getByTestId('archived-row-restore') - .click(); - await expect( - page.getByText(`Failed to restore ${name}`, { exact: false }), - ).toBeVisible({ timeout: 15000 }); - // The page is still functional (the list view did not crash). - await expect(page.getByTestId('archived-list-view')).toBeVisible(); - } finally { - // Re-archive the (possibly) restored dashboard, whatever happened above. - await apiDeleteDashboard(page, id).catch(() => {}); - } -}); diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts index 6d167787d3da..00f7ee10af33 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts @@ -467,6 +467,14 @@ export function transformSeries( return formatter(numericValue); } if (!onlyTotal) { + // A stacked segment with no height begins and ends at the same + // coordinate as the top of the segment beneath it, so its label is + // drawn over that segment's label. Zero and null have no height, so + // they carry no label. The rich tooltip omits zero observations from + // a stacked series for the same reason. + if (stack && !numericValue) { + return ''; + } if ( numericValue >= (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER) diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts index 84022759a503..604420876375 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts @@ -20,13 +20,14 @@ import { CategoricalColorScale, ChartProps, TimeGranularity, + getNumberFormatter, } from '@superset-ui/core'; import { GenericDataType } from '@apache-superset/core/common'; import { supersetTheme } from '@apache-superset/core/theme'; import type { SeriesOption } from 'echarts'; import type { ScatterSeriesOption } from 'echarts/charts'; import { EchartsTimeseriesSeriesType } from '../../src'; -import { TIMESERIES_CONSTANTS } from '../../src/constants'; +import { StackControlsValue, TIMESERIES_CONSTANTS } from '../../src/constants'; import { LegendOrientation, EchartsTimeseriesChartProps, @@ -566,3 +567,70 @@ test('getPadding should handle Left position with zero margin correctly', () => getChartPaddingSpy.mockRestore(); } }); + +/** + * #42702: a stacked segment with no height starts and ends at the same + * coordinate as the top of the segment beneath it, so a value label on it is + * drawn over that segment's label. `percentage_threshold` does not filter these + * out: it defaults to 0, and `thresholdValues[dataIndex] || MIN_SAFE_INTEGER` + * turns a 0 threshold into "no filtering", which is intentional. + */ +const stackedLabel = ( + numericValue: number | null, + opts: Record = {}, +) => { + const series = transformSeries( + { id: 'B', name: 'B', data: [[1, numericValue]] } as SeriesOption, + mockColorScale, + 'B', + { + seriesType: EchartsTimeseriesSeriesType.Bar, + stack: StackControlsValue.Stack, + showValue: true, + onlyTotal: false, + formatter: getNumberFormatter(), + thresholdValues: [0], + ...opts, + }, + ) as SeriesOption & { + label: { formatter: (params: unknown) => string }; + }; + return series.label.formatter({ + value: [1, numericValue], + dataIndex: 0, + seriesIndex: 1, + seriesName: 'B', + }); +}; + +test('stacked value labels are omitted for a zero-height segment', () => { + expect(stackedLabel(0)).toBe(''); + expect(stackedLabel(null)).toBe(''); +}); + +test('stacked value labels are kept for segments that have height', () => { + expect(stackedLabel(32)).toBe('32'); + expect(stackedLabel(-5)).toBe('-5'); +}); + +test('a zero value keeps its label when the series is not stacked', () => { + // Without a stack the label sits on the bar itself, so there is nothing for + // it to collide with. + expect(stackedLabel(0, { stack: undefined })).toBe('0'); +}); + +test('percentage_threshold still filters values below the threshold', () => { + // 10% of a 100 total. The zero-height guard must not swallow this rule. + expect(stackedLabel(5, { thresholdValues: [10] })).toBe(''); + expect(stackedLabel(50, { thresholdValues: [10] })).toBe('50'); +}); + +test('only-total labels are unaffected by the zero-height guard', () => { + expect( + stackedLabel(0, { + onlyTotal: true, + showValueIndexes: [1], + totalStackedValues: [32], + }), + ).toBe('32'); +}); diff --git a/superset-frontend/src/components/Chart/chartReducer.ts b/superset-frontend/src/components/Chart/chartReducer.ts index e4f4138b0959..65e3c7f01c81 100644 --- a/superset-frontend/src/components/Chart/chartReducer.ts +++ b/superset-frontend/src/components/Chart/chartReducer.ts @@ -223,6 +223,11 @@ export default function chartReducer( } if (action.type in actionHandlers) { + // ADD_CHART creates the entry, so it runs without prior state; every other + // handler reads state that is absent once the chart has been removed + if (action.type !== actions.ADD_CHART && !charts[action.key]) { + return charts; + } return { ...charts, [action.key]: actionHandlers[action.type](charts[action.key]), diff --git a/superset-frontend/src/components/Chart/chartReducers.test.ts b/superset-frontend/src/components/Chart/chartReducers.test.ts index d5b660dd8105..45f2402f5381 100644 --- a/superset-frontend/src/components/Chart/chartReducers.test.ts +++ b/superset-frontend/src/components/Chart/chartReducers.test.ts @@ -91,4 +91,20 @@ describe('chart reducers', () => { expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0); expect(newState[chartKey].chartStatus).toEqual('failed'); }); + + test('ignores an action for a chart that is no longer in state', () => { + const action = actions.chartUpdateStopped(999, new AbortController()); + expect(() => chartReducer(charts, action)).not.toThrow(); + expect(chartReducer(charts, action)).toEqual(charts); + }); + + test('still adds a chart that is not yet in state', () => { + const newChartKey = 2; + const newState = chartReducer( + charts, + actions.addChart({ ...chart, id: newChartKey }, newChartKey), + ); + expect(newState[newChartKey].id).toEqual(newChartKey); + expect(newState[chartKey]).toEqual(testChart); + }); }); diff --git a/superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx b/superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx index 3aa8a16fa714..9bc75c4f6161 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx @@ -105,10 +105,17 @@ export const SamplesPane = ({ 1, ) .then(response => { - setData(ensureIsArray(response.data)); - setColnames(ensureIsArray(response.colnames)); - setColtypes(ensureIsArray(response.coltypes)); - setRowCount(response.rowcount); + // A 200 that carries no `result` payload resolves to undefined here. + // Read through it so the pane falls back to its empty state instead + // of throwing a TypeError that surfaces as an internal error message. + const rows = ensureIsArray(response?.data); + setData(rows); + setColnames(ensureIsArray(response?.colnames)); + setColtypes(ensureIsArray(response?.coltypes)); + // Fall back to the rows actually returned rather than to zero: the + // controls only render when there are rows, and a hardcoded 0 would + // label a populated table as "0 rows". + setRowCount(response?.rowcount ?? rows.length); setResponseError(''); cache.set(queryFormData, true); if (queryForce) { diff --git a/superset-frontend/src/explore/components/DataTablesPane/test/SamplesPane.test.tsx b/superset-frontend/src/explore/components/DataTablesPane/test/SamplesPane.test.tsx index 02b5fed72908..b358701f59c9 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/test/SamplesPane.test.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/test/SamplesPane.test.tsx @@ -60,6 +60,27 @@ describe('SamplesPane', () => { 400, ); + // A 200 response that carries no `result` payload, as reported in #36840. + fetchMock.post( + 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=37&per_page=100&page=1', + {}, + ); + + // A 200 whose result carries rows but omits `rowcount`. + fetchMock.post( + 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=38&per_page=100&page=1', + { + result: { + data: [ + { __timestamp: 1230768000000, genre: 'Action' }, + { __timestamp: 1230768000010, genre: 'Horror' }, + ], + colnames: ['__timestamp', 'genre'], + coltypes: [2, 1], + }, + }, + ); + const setForceQuery = jest.fn(); afterAll(() => { @@ -114,4 +135,29 @@ describe('SamplesPane', () => { expect(queryByText('Action')).toBeVisible(); expect(queryByText('Horror')).toBeVisible(); }); + + test('renders the empty state when the response carries no result payload', async () => { + const props = createSamplesPaneProps({ datasourceId: 37 }); + const { findByText, queryByRole } = render(, { + useRedux: true, + }); + + expect( + await findByText('No samples were returned for this dataset'), + ).toBeVisible(); + // The pane should not leak an internal TypeError through the error alert. + expect(queryByRole('alert')).not.toBeInTheDocument(); + }); + + test('counts the returned rows when the response omits rowcount', async () => { + const props = createSamplesPaneProps({ datasourceId: 38 }); + const { findByText, queryByText } = render(, { + useRedux: true, + }); + + expect(await findByText('Action')).toBeVisible(); + // Falling back to 0 here would label a populated table as "0 rows". + expect(queryByText('0 rows')).not.toBeInTheDocument(); + expect(queryByText('2 rows')).toBeVisible(); + }); }); diff --git a/superset-frontend/src/pages/ArchivedList/ArchivedList.test.tsx b/superset-frontend/src/pages/ArchivedList/ArchivedList.test.tsx index ee9e29083a78..360f682898bf 100644 --- a/superset-frontend/src/pages/ArchivedList/ArchivedList.test.tsx +++ b/superset-frontend/src/pages/ArchivedList/ArchivedList.test.tsx @@ -141,6 +141,7 @@ const renderArchivedList = (withStore = store) => beforeEach(() => { fetchMock.removeRoutes(); fetchMock.clearHistory(); + mockAddDangerToast.mockClear(); }); test('renders archived rows with Name and Type columns', async () => { @@ -204,6 +205,31 @@ test('restore failure surfaces an error and leaves the row in place', async () = expect(screen.getByText('Deleted Chart One')).toBeInTheDocument(); }); +test('restoring an already-restored row (404) surfaces an error without crashing', async () => { + // Simulates another actor having restored the object out from under this + // view: the server answers 404 to the now-stale row's restore request. + mockRoutes(404); + renderArchivedList(); + await screen.findByTestId('archived-list-view'); + + const restoreButtons = await screen.findAllByTestId('archived-row-restore'); + fireEvent.click(restoreButtons[0]); + + await waitFor(() => { + expect(fetchMock.callHistory.calls(/chart\/uuid-1\/restore/)).toHaveLength( + 1, + ); + }); + await waitFor(() => { + expect(mockAddDangerToast).toHaveBeenCalledWith( + expect.stringContaining('Failed to restore Deleted Chart One'), + ); + }); + expect(mockAddDangerToast).toHaveBeenCalledTimes(1); + // The page is still functional -- the list view did not crash. + expect(screen.getByTestId('archived-list-view')).toBeInTheDocument(); +}); + test('row actions are keyboard-operable (Enter restores)', async () => { mockRoutes(); renderArchivedList(); @@ -273,6 +299,45 @@ test('name search refetches with a contains filter on the name field', async () }); }); +test('a search that matches nothing shows the empty-state and no restore actions', async () => { + // The initial load returns real rows; only the search-triggered request + // answers empty. If the list were empty from the start, this test could + // pass even if the search never fired a request at all -- so the request + // itself is asserted below before trusting the rendered empty state. + fetchMock.get(infoEndpoint, { permissions: ['can_read', 'can_write'] }); + fetchMock.getOnce(listEndpoint, { + result: mockCharts, + count: mockCharts.length, + }); + fetchMock.get(listEndpoint, { result: [], count: 0 }); + renderArchivedList(); + await screen.findByText('Deleted Chart One'); + + const searchInput = screen.getByPlaceholderText(/type a value/i); + fireEvent.change(searchInput, { target: { value: 'e2e_nonexistent' } }); + fireEvent.keyDown(searchInput, { key: 'Enter', keyCode: 13 }); + + await waitFor(() => { + const hit = fetchMock.callHistory + .calls(/chart\/\?q/) + .find(call => + call.url.includes( + '(col:slice_name,opr:chart_all_text,value:e2e_nonexistent)', + ), + ); + expect(hit).toBeTruthy(); + }); + + // ListView renders this hardcoded copy whenever a filter is active and the + // result set is empty, overriding the page's own `emptyState` prop + // entirely (see ListView.tsx) -- so this is the actual rendered text, not + // the page's "No archived items" default. + expect( + await screen.findByText('No results match your filter criteria'), + ).toBeInTheDocument(); + expect(screen.queryAllByTestId('archived-row-restore')).toHaveLength(0); +}); + test('switching Type fetches the newly selected resource with its deleted-state filter', async () => { mockRoutes(); renderArchivedList(); diff --git a/superset-frontend/src/pages/ChartList/ChartList.test.tsx b/superset-frontend/src/pages/ChartList/ChartList.test.tsx index 85eb98408bdd..d577743e7656 100644 --- a/superset-frontend/src/pages/ChartList/ChartList.test.tsx +++ b/superset-frontend/src/pages/ChartList/ChartList.test.tsx @@ -239,6 +239,40 @@ describe('ChartList', () => { screen.getByRole('button', { name: 'Bulk select' }), ).toBeInTheDocument(); }); + + test('archive (soft-delete) confirmation reflects recoverable semantics, not delete', async () => { + // With SOFT_DELETE on, the same delete affordance becomes reversible: the + // dialog reads "Archive", not "Delete", and drops the "type DELETE to + // confirm" gate -- that friction is reserved for the permanent purge in + // the Recently Archived view, not this one. + ( + isFeatureEnabled as jest.MockedFunction + ).mockImplementation((feature: string) => feature === 'SOFT_DELETE'); + + // isUserEditorOrAdmin requires `username` + `permissions` to recognize an + // Admin role (see src/types/bootstrapTypes.ts's isUserWithPermissionsAndRoles); + // mockUser lacks both, so row actions would otherwise render disabled. + const adminUser = { ...mockUser, username: 'admin', permissions: {} }; + renderChartList(adminUser); + await screen.findByTestId('chart-list-view'); + + const deleteButtons = await screen.findAllByTestId('chart-row-delete'); + fireEvent.click(deleteButtons[0]); + + const dialog = await screen.findByRole('dialog'); + expect( + within(dialog).getByText(`Archive ${mockCharts[0].slice_name}?`), + ).toBeInTheDocument(); + expect( + within(dialog).getByRole('button', { name: 'Archive' }), + ).toBeInTheDocument(); + expect( + within(dialog).getByText(/moved to Recently Archived/i), + ).toBeInTheDocument(); + expect(within(dialog).getByText(/recover it there/i)).toBeInTheDocument(); + + expect(screen.queryByTestId('delete-modal-input')).not.toBeInTheDocument(); + }); }); // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks diff --git a/superset/cli/test_db.py b/superset/cli/test_db.py index c4877bb66488..124efdb7eb32 100644 --- a/superset/cli/test_db.py +++ b/superset/cli/test_db.py @@ -280,9 +280,6 @@ def test_sqlalchemy_dialect( """ Test the SQLAlchemy dialect, making sure it supports everything Superset needs. """ - if "future" not in engine_kwargs: - engine_kwargs["future"] = True - engine = create_engine(sqlalchemy_uri, **engine_kwargs) dialect = engine.dialect diff --git a/superset/commands/streaming_export/base.py b/superset/commands/streaming_export/base.py index 1113c2eff99f..9bf58aec9ff9 100644 --- a/superset/commands/streaming_export/base.py +++ b/superset/commands/streaming_export/base.py @@ -227,7 +227,7 @@ def _execute_query_and_stream( delimiter = csv_export_config.get("sep", ",") decimal_separator = csv_export_config.get("decimal", ".") - with db.session(future=True) as session: + with db.session() as session: # Merge database to prevent DetachedInstanceError merged_database = session.merge(database) diff --git a/superset/common/query_context_factory.py b/superset/common/query_context_factory.py index f83661825aa3..5a310749cfa8 100644 --- a/superset/common/query_context_factory.py +++ b/superset/common/query_context_factory.py @@ -291,19 +291,30 @@ def _apply_granularity( # noqa: C901 ), None, ) - # Replaces x-axis column values with granularity + # Point the x-axis at the overridden Time Column (granularity). if x_axis_column: if isinstance(x_axis_column, dict): + # Only swap the underlying expression, keeping the + # column's original label. The temporal offset join + # (``processing_time_offsets``), the post-processing + # pivot ``index`` and the frontend all reference this + # column by its label; renaming it to the granularity + # here desynchronizes those consumers from the label + # the saved chart still advertises, which — with a Time + # Comparison offset — collapses the series into a single + # point. x_axis_column["sqlExpression"] = granularity - x_axis_column["label"] = granularity else: + # A bare string x-axis has no distinct label, so it is + # replaced wholesale and the pivot ``index`` must be + # realigned to the overridden column. query_object.columns = [ granularity if column == x_axis_column else column for column in query_object.columns ] - for post_processing in query_object.post_processing: - if post_processing.get("operation") == "pivot": - post_processing["options"]["index"] = [granularity] + for post_processing in query_object.post_processing: + if post_processing.get("operation") == "pivot": + post_processing["options"]["index"] = [granularity] # If no temporal x-axis, then get the default temporal filter if not filter_to_remove: diff --git a/superset/db_engine_specs/gsheets.py b/superset/db_engine_specs/gsheets.py index f74844975e30..9dc85bc56c38 100644 --- a/superset/db_engine_specs/gsheets.py +++ b/superset/db_engine_specs/gsheets.py @@ -389,7 +389,6 @@ def validate_parameters( } } }, - future=True, ) conn = engine.connect() idx = 0 diff --git a/superset/migrations/shared/catalogs.py b/superset/migrations/shared/catalogs.py index 9cb98af26ea6..77f1bcf188ff 100644 --- a/superset/migrations/shared/catalogs.py +++ b/superset/migrations/shared/catalogs.py @@ -376,7 +376,7 @@ def upgrade_catalog_perms(engines: set[str] | None = None) -> None: """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # The Database model has an eager-loaded (``lazy="joined"``) ``ssh_tunnel`` # backref. Eager-loading it here would SELECT every column on ``ssh_tunnels``, @@ -581,7 +581,7 @@ def downgrade_catalog_perms(engines: set[str] | None = None) -> None: WARNING: models (datasets and charts) not in the default catalog are deleted! """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # See upgrade_catalog_perms: avoid eager-loading the ``ssh_tunnel`` backref so the # query stays schema-safe across migration revisions. diff --git a/superset/migrations/versions/2016-04-25_08-54_c3a8f8611885_materializing_permission.py b/superset/migrations/versions/2016-04-25_08-54_c3a8f8611885_materializing_permission.py index 0c742c70862c..748975fd5609 100644 --- a/superset/migrations/versions/2016-04-25_08-54_c3a8f8611885_materializing_permission.py +++ b/superset/migrations/versions/2016-04-25_08-54_c3a8f8611885_materializing_permission.py @@ -51,7 +51,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() op.add_column("slices", sa.Column("perm", sa.String(length=2000), nullable=True)) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Use Slice class defined here instead of models.Slice for slc in session.query(Slice).all(): diff --git a/superset/migrations/versions/2016-06-07_12-33_d8bc074f7aad_add_new_field_is_restricted_to_.py b/superset/migrations/versions/2016-06-07_12-33_d8bc074f7aad_add_new_field_is_restricted_to_.py index 223c0d6eb874..748ed4b36584 100644 --- a/superset/migrations/versions/2016-06-07_12-33_d8bc074f7aad_add_new_field_is_restricted_to_.py +++ b/superset/migrations/versions/2016-06-07_12-33_d8bc074f7aad_add_new_field_is_restricted_to_.py @@ -59,7 +59,7 @@ def upgrade(): ) bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # don't use models.DruidMetric # because it assumes the context is consistent with the application diff --git a/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py b/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py index 95a6b0735c36..8164e76875b1 100644 --- a/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py +++ b/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py @@ -94,7 +94,7 @@ class Dashboard(AuditMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) objects = session.query(Slice).all() objects += session.query(Dashboard).all() diff --git a/superset/migrations/versions/2016-09-07_23-50_33d996bcc382_update_slice_model.py b/superset/migrations/versions/2016-09-07_23-50_33d996bcc382_update_slice_model.py index ded43bb58ca1..79da3e3e7909 100644 --- a/superset/migrations/versions/2016-09-07_23-50_33d996bcc382_update_slice_model.py +++ b/superset/migrations/versions/2016-09-07_23-50_33d996bcc382_update_slice_model.py @@ -50,7 +50,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() op.add_column("slices", sa.Column("datasource_id", sa.Integer())) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.druid_datasource_id: @@ -63,7 +63,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.datasource_type == "druid": slc.druid_datasource_id = slc.datasource_id diff --git a/superset/migrations/versions/2016-09-22_11-31_eca4694defa7_sqllab_setting_defaults.py b/superset/migrations/versions/2016-09-22_11-31_eca4694defa7_sqllab_setting_defaults.py index d1f9884b1404..06a83803da76 100644 --- a/superset/migrations/versions/2016-09-22_11-31_eca4694defa7_sqllab_setting_defaults.py +++ b/superset/migrations/versions/2016-09-22_11-31_eca4694defa7_sqllab_setting_defaults.py @@ -45,7 +45,7 @@ class Database(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for obj in session.query(Database).all(): obj.allow_run_sync = True diff --git a/superset/migrations/versions/2017-01-24_12-31_db0c65b146bd_update_slice_model_json.py b/superset/migrations/versions/2017-01-24_12-31_db0c65b146bd_update_slice_model_json.py index e41b563a4ef0..387c14bb608d 100644 --- a/superset/migrations/versions/2017-01-24_12-31_db0c65b146bd_update_slice_model_json.py +++ b/superset/migrations/versions/2017-01-24_12-31_db0c65b146bd_update_slice_model_json.py @@ -48,7 +48,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).all() slice_len = len(slices) diff --git a/superset/migrations/versions/2017-02-08_14-16_a99f2f7c195a_rewriting_url_from_shortner_with_new_.py b/superset/migrations/versions/2017-02-08_14-16_a99f2f7c195a_rewriting_url_from_shortner_with_new_.py index 3754867eeb3a..a03588fb6ef4 100644 --- a/superset/migrations/versions/2017-02-08_14-16_a99f2f7c195a_rewriting_url_from_shortner_with_new_.py +++ b/superset/migrations/versions/2017-02-08_14-16_a99f2f7c195a_rewriting_url_from_shortner_with_new_.py @@ -61,7 +61,7 @@ class Url(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) urls = session.query(Url).all() urls_len = len(urls) diff --git a/superset/migrations/versions/2017-12-08_08-19_67a6ac9b727b_update_spatial_params.py b/superset/migrations/versions/2017-12-08_08-19_67a6ac9b727b_update_spatial_params.py index 36dabd086fe4..c2c1ee8dbd64 100644 --- a/superset/migrations/versions/2017-12-08_08-19_67a6ac9b727b_update_spatial_params.py +++ b/superset/migrations/versions/2017-12-08_08-19_67a6ac9b727b_update_spatial_params.py @@ -45,7 +45,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type.like("deck_%")): params = json.loads(slc.params) diff --git a/superset/migrations/versions/2017-12-17_11-06_21e88bc06c02_annotation_migration.py b/superset/migrations/versions/2017-12-17_11-06_21e88bc06c02_annotation_migration.py index 9d9167c264bc..45c5588961c3 100644 --- a/superset/migrations/versions/2017-12-17_11-06_21e88bc06c02_annotation_migration.py +++ b/superset/migrations/versions/2017-12-17_11-06_21e88bc06c02_annotation_migration.py @@ -45,7 +45,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter( or_(Slice.viz_type.like("line"), Slice.viz_type.like("bar")) @@ -75,7 +75,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter( or_(Slice.viz_type.like("line"), Slice.viz_type.like("bar")) diff --git a/superset/migrations/versions/2018-02-13_08-07_e866bd2d4976_smaller_grid.py b/superset/migrations/versions/2018-02-13_08-07_e866bd2d4976_smaller_grid.py index 65121c70fdad..cc85cce3e72a 100644 --- a/superset/migrations/versions/2018-02-13_08-07_e866bd2d4976_smaller_grid.py +++ b/superset/migrations/versions/2018-02-13_08-07_e866bd2d4976_smaller_grid.py @@ -46,7 +46,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): @@ -68,7 +68,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): diff --git a/superset/migrations/versions/2018-04-03_08-19_130915240929_is_sqllab_viz_flow.py b/superset/migrations/versions/2018-04-03_08-19_130915240929_is_sqllab_viz_flow.py index 7704f75168a2..0efed690f54a 100644 --- a/superset/migrations/versions/2018-04-03_08-19_130915240929_is_sqllab_viz_flow.py +++ b/superset/migrations/versions/2018-04-03_08-19_130915240929_is_sqllab_viz_flow.py @@ -57,7 +57,7 @@ def upgrade(): ), ) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Use Slice class defined here instead of models.Slice for tbl in session.query(Table).all(): diff --git a/superset/migrations/versions/2018-04-10_11-19_bf706ae5eb46_cal_heatmap_metric_to_metrics.py b/superset/migrations/versions/2018-04-10_11-19_bf706ae5eb46_cal_heatmap_metric_to_metrics.py index a3d0308818ca..e96750bdb070 100644 --- a/superset/migrations/versions/2018-04-10_11-19_bf706ae5eb46_cal_heatmap_metric_to_metrics.py +++ b/superset/migrations/versions/2018-04-10_11-19_bf706ae5eb46_cal_heatmap_metric_to_metrics.py @@ -49,7 +49,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter_by(viz_type="cal_heatmap").all() slice_len = len(slices) diff --git a/superset/migrations/versions/2018-06-04_11-12_c5756bec8b47_time_grain_sqla.py b/superset/migrations/versions/2018-06-04_11-12_c5756bec8b47_time_grain_sqla.py index 5c2eee08ff6f..f1d48a085c82 100644 --- a/superset/migrations/versions/2018-06-04_11-12_c5756bec8b47_time_grain_sqla.py +++ b/superset/migrations/versions/2018-06-04_11-12_c5756bec8b47_time_grain_sqla.py @@ -45,7 +45,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: @@ -63,7 +63,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2018-06-07_09-52_afb7730f6a9c_remove_empty_filters.py b/superset/migrations/versions/2018-06-07_09-52_afb7730f6a9c_remove_empty_filters.py index d2a601760f9d..e67462e15982 100644 --- a/superset/migrations/versions/2018-06-07_09-52_afb7730f6a9c_remove_empty_filters.py +++ b/superset/migrations/versions/2018-06-07_09-52_afb7730f6a9c_remove_empty_filters.py @@ -45,7 +45,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2018-06-13_10-20_4451805bbaa1_remove_double_percents.py b/superset/migrations/versions/2018-06-13_10-20_4451805bbaa1_remove_double_percents.py index f347206bad2c..7cc33d966005 100644 --- a/superset/migrations/versions/2018-06-13_10-20_4451805bbaa1_remove_double_percents.py +++ b/superset/migrations/versions/2018-06-13_10-20_4451805bbaa1_remove_double_percents.py @@ -68,7 +68,7 @@ class Database(Base): def replace(source, target): - with db.Session(bind=op.get_bind(), future=True) as session: + with db.Session(bind=op.get_bind()) as session: with session.begin(): query = ( session.query(Slice, Database) @@ -80,7 +80,7 @@ def replace(source, target): for slc, database in query: try: - engine = create_engine(database.sqlalchemy_uri, future=True) + engine = create_engine(database.sqlalchemy_uri) if engine.dialect.identifier_preparer._double_percents: params = json.loads(slc.params) diff --git a/superset/migrations/versions/2018-06-13_14-54_bddc498dd179_adhoc_filters.py b/superset/migrations/versions/2018-06-13_14-54_bddc498dd179_adhoc_filters.py index e84cb6a86077..0d7fd3051e5a 100644 --- a/superset/migrations/versions/2018-06-13_14-54_bddc498dd179_adhoc_filters.py +++ b/superset/migrations/versions/2018-06-13_14-54_bddc498dd179_adhoc_filters.py @@ -50,7 +50,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: @@ -66,7 +66,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2018-06-14_14-31_80a67c5192fa_single_pie_chart_metric.py b/superset/migrations/versions/2018-06-14_14-31_80a67c5192fa_single_pie_chart_metric.py index c7ba9141711f..8a7dbeaf407c 100644 --- a/superset/migrations/versions/2018-06-14_14-31_80a67c5192fa_single_pie_chart_metric.py +++ b/superset/migrations/versions/2018-06-14_14-31_80a67c5192fa_single_pie_chart_metric.py @@ -47,7 +47,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "pie").all(): try: @@ -68,7 +68,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "pie").all(): try: diff --git a/superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py b/superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py index bf2a230cfdc2..7db90149a83d 100644 --- a/superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py +++ b/superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py @@ -134,7 +134,7 @@ def compute_time_compare(granularity, periods): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for chart in session.query(Slice): params = json.loads(chart.params or "{}") @@ -163,7 +163,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for chart in session.query(Slice): params = json.loads(chart.params or "{}") diff --git a/superset/migrations/versions/2018-07-19_23-41_c617da68de7d_form_nullable.py b/superset/migrations/versions/2018-07-19_23-41_c617da68de7d_form_nullable.py index 808e24a63dbd..63bf45ece271 100644 --- a/superset/migrations/versions/2018-07-19_23-41_c617da68de7d_form_nullable.py +++ b/superset/migrations/versions/2018-07-19_23-41_c617da68de7d_form_nullable.py @@ -159,7 +159,7 @@ class TableColumn(BaseColumnMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) tables = [ Annotation, diff --git a/superset/migrations/versions/2018-07-20_15-31_7f2635b51f5d_update_base_columns.py b/superset/migrations/versions/2018-07-20_15-31_7f2635b51f5d_update_base_columns.py index ca02ef0bb24a..637b26f7a357 100644 --- a/superset/migrations/versions/2018-07-20_15-31_7f2635b51f5d_update_base_columns.py +++ b/superset/migrations/versions/2018-07-20_15-31_7f2635b51f5d_update_base_columns.py @@ -59,7 +59,7 @@ class TableColumn(BaseColumnMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Delete the orphaned columns records. for record in session.query(DruidColumn).all(): diff --git a/superset/migrations/versions/2018-07-20_15-57_e9df189e5c7e_update_base_metrics.py b/superset/migrations/versions/2018-07-20_15-57_e9df189e5c7e_update_base_metrics.py index 570bc02f19d3..5addda200cf0 100644 --- a/superset/migrations/versions/2018-07-20_15-57_e9df189e5c7e_update_base_metrics.py +++ b/superset/migrations/versions/2018-07-20_15-57_e9df189e5c7e_update_base_metrics.py @@ -59,7 +59,7 @@ class SqlMetric(BaseMetricMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Delete the orphaned metrics records. for record in session.query(DruidMetric).all(): diff --git a/superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py b/superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py index a3ba04be2790..731945f45f8f 100644 --- a/superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py +++ b/superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py @@ -579,7 +579,7 @@ def scan_dashboard_positions_data(positions): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): diff --git a/superset/migrations/versions/2018-08-01_11-47_7fcdcde0761c_.py b/superset/migrations/versions/2018-08-01_11-47_7fcdcde0761c_.py index 4c8cda051c7e..ef891a210acf 100644 --- a/superset/migrations/versions/2018-08-01_11-47_7fcdcde0761c_.py +++ b/superset/migrations/versions/2018-08-01_11-47_7fcdcde0761c_.py @@ -55,7 +55,7 @@ def is_v2_dash(positions): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): # noqa: B007 diff --git a/superset/migrations/versions/2018-11-12_13-31_4ce8df208545_migrate_time_range_for_default_filters.py b/superset/migrations/versions/2018-11-12_13-31_4ce8df208545_migrate_time_range_for_default_filters.py index 379671cf3b0d..33ad74942e04 100644 --- a/superset/migrations/versions/2018-11-12_13-31_4ce8df208545_migrate_time_range_for_default_filters.py +++ b/superset/migrations/versions/2018-11-12_13-31_4ce8df208545_migrate_time_range_for_default_filters.py @@ -46,7 +46,7 @@ class Dashboard(Base): def upgrade(): # noqa: C901 bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): diff --git a/superset/migrations/versions/2018-12-11_22-03_fb13d49b72f9_better_filters.py b/superset/migrations/versions/2018-12-11_22-03_fb13d49b72f9_better_filters.py index 64fab00f95c7..916ed5549684 100644 --- a/superset/migrations/versions/2018-12-11_22-03_fb13d49b72f9_better_filters.py +++ b/superset/migrations/versions/2018-12-11_22-03_fb13d49b72f9_better_filters.py @@ -75,7 +75,7 @@ def upgrade_slice(slc): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) filter_box_slices = session.query(Slice).filter_by(viz_type="filter_box") for slc in filter_box_slices.all(): @@ -90,7 +90,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) filter_box_slices = session.query(Slice).filter_by(viz_type="filter_box") for slc in filter_box_slices.all(): diff --git a/superset/migrations/versions/2018-12-15_12-34_3e1b21cd94a4_change_owner_to_m2m_relation_on_.py b/superset/migrations/versions/2018-12-15_12-34_3e1b21cd94a4_change_owner_to_m2m_relation_on_.py index b69f15281fc7..7a1b43331bc5 100644 --- a/superset/migrations/versions/2018-12-15_12-34_3e1b21cd94a4_change_owner_to_m2m_relation_on_.py +++ b/superset/migrations/versions/2018-12-15_12-34_3e1b21cd94a4_change_owner_to_m2m_relation_on_.py @@ -87,7 +87,7 @@ def upgrade(): bind = op.get_bind() insp = sa.engine.reflection.Inspector.from_engine(bind) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) tables = session.query(SqlaTable).all() for table in tables: diff --git a/superset/migrations/versions/2019-03-21_10-22_d94d33dbe938_form_strip.py b/superset/migrations/versions/2019-03-21_10-22_d94d33dbe938_form_strip.py index 340ee8d32650..5a744dd925ca 100644 --- a/superset/migrations/versions/2019-03-21_10-22_d94d33dbe938_form_strip.py +++ b/superset/migrations/versions/2019-03-21_10-22_d94d33dbe938_form_strip.py @@ -159,7 +159,7 @@ class TableColumn(BaseColumnMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) tables = [ Annotation, diff --git a/superset/migrations/versions/2019-04-09_16-27_80aa3f04bc82_add_parent_ids_in_dashboard_layout.py b/superset/migrations/versions/2019-04-09_16-27_80aa3f04bc82_add_parent_ids_in_dashboard_layout.py index 12504488bf55..8df0554dcead 100644 --- a/superset/migrations/versions/2019-04-09_16-27_80aa3f04bc82_add_parent_ids_in_dashboard_layout.py +++ b/superset/migrations/versions/2019-04-09_16-27_80aa3f04bc82_add_parent_ids_in_dashboard_layout.py @@ -62,7 +62,7 @@ def add_parent_ids(node, layout): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): @@ -88,7 +88,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): diff --git a/superset/migrations/versions/2019-06-28_13-17_ab8c66efdd01_resample.py b/superset/migrations/versions/2019-06-28_13-17_ab8c66efdd01_resample.py index c5b4708da87f..a9060680bdb5 100644 --- a/superset/migrations/versions/2019-06-28_13-17_ab8c66efdd01_resample.py +++ b/superset/migrations/versions/2019-06-28_13-17_ab8c66efdd01_resample.py @@ -47,7 +47,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: @@ -94,7 +94,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2019-07-15_12-00_190188938582_adding_unique_constraint_on_dashboard_slices_tbl.py b/superset/migrations/versions/2019-07-15_12-00_190188938582_adding_unique_constraint_on_dashboard_slices_tbl.py index 7697521bd675..59ca97c41001 100644 --- a/superset/migrations/versions/2019-07-15_12-00_190188938582_adding_unique_constraint_on_dashboard_slices_tbl.py +++ b/superset/migrations/versions/2019-07-15_12-00_190188938582_adding_unique_constraint_on_dashboard_slices_tbl.py @@ -46,7 +46,7 @@ class DashboardSlices(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # find dup records in dashboard_slices tbl dup_records = ( diff --git a/superset/migrations/versions/2019-09-11_21-49_5afa9079866a_serialize_schema_permissions_py.py b/superset/migrations/versions/2019-09-11_21-49_5afa9079866a_serialize_schema_permissions_py.py index e0378995a27b..99424e060070 100644 --- a/superset/migrations/versions/2019-09-11_21-49_5afa9079866a_serialize_schema_permissions_py.py +++ b/superset/migrations/versions/2019-09-11_21-49_5afa9079866a_serialize_schema_permissions_py.py @@ -71,7 +71,7 @@ def upgrade(): op.add_column("tables", Column("schema_perm", String(length=1000), nullable=True)) bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for t in session.query(Sqlatable).all(): db_name = ( t.database.verbose_name diff --git a/superset/migrations/versions/2019-09-19_13-40_258b5280a45e_form_strip_leading_and_trailing_whitespace.py b/superset/migrations/versions/2019-09-19_13-40_258b5280a45e_form_strip_leading_and_trailing_whitespace.py index c0bfecee6f23..8838d43980f2 100644 --- a/superset/migrations/versions/2019-09-19_13-40_258b5280a45e_form_strip_leading_and_trailing_whitespace.py +++ b/superset/migrations/versions/2019-09-19_13-40_258b5280a45e_form_strip_leading_and_trailing_whitespace.py @@ -161,7 +161,7 @@ class TableColumn(BaseColumnMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) tables = [ Annotation, diff --git a/superset/migrations/versions/2019-10-10_13-52_1495eb914ad3_time_range.py b/superset/migrations/versions/2019-10-10_13-52_1495eb914ad3_time_range.py index 0d2e1db2a336..3ae6d7c8b4c1 100644 --- a/superset/migrations/versions/2019-10-10_13-52_1495eb914ad3_time_range.py +++ b/superset/migrations/versions/2019-10-10_13-52_1495eb914ad3_time_range.py @@ -48,7 +48,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: @@ -63,7 +63,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2019-11-06_15-23_78ee127d0d1d_reconvert_legacy_filters_into_adhoc.py b/superset/migrations/versions/2019-11-06_15-23_78ee127d0d1d_reconvert_legacy_filters_into_adhoc.py index c169fad6ab7a..228b6adc62cd 100644 --- a/superset/migrations/versions/2019-11-06_15-23_78ee127d0d1d_reconvert_legacy_filters_into_adhoc.py +++ b/superset/migrations/versions/2019-11-06_15-23_78ee127d0d1d_reconvert_legacy_filters_into_adhoc.py @@ -53,7 +53,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.params: diff --git a/superset/migrations/versions/2020-02-07_14-13_3325d4caccc8_dashboard_scoped_filters.py b/superset/migrations/versions/2020-02-07_14-13_3325d4caccc8_dashboard_scoped_filters.py index 1c3010a7a9f3..b2b589a4ced7 100644 --- a/superset/migrations/versions/2020-02-07_14-13_3325d4caccc8_dashboard_scoped_filters.py +++ b/superset/migrations/versions/2020-02-07_14-13_3325d4caccc8_dashboard_scoped_filters.py @@ -69,7 +69,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = session.query(Dashboard).all() for i, dashboard in enumerate(dashboards): diff --git a/superset/migrations/versions/2020-03-25_10-42_f9a30386bd74_cleanup_time_grainularity.py b/superset/migrations/versions/2020-03-25_10-42_f9a30386bd74_cleanup_time_grainularity.py index 3a90d5bf6ff1..69771c42b0e4 100644 --- a/superset/migrations/versions/2020-03-25_10-42_f9a30386bd74_cleanup_time_grainularity.py +++ b/superset/migrations/versions/2020-03-25_10-42_f9a30386bd74_cleanup_time_grainularity.py @@ -56,7 +56,7 @@ def upgrade(): """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Visualization types which support time granularity (hence negate). viz_types = [ diff --git a/superset/migrations/versions/2020-04-29_09-24_620241d1153f_update_time_grain_sqla.py b/superset/migrations/versions/2020-04-29_09-24_620241d1153f_update_time_grain_sqla.py index 90c245bfe1ca..361d459ce1eb 100644 --- a/superset/migrations/versions/2020-04-29_09-24_620241d1153f_update_time_grain_sqla.py +++ b/superset/migrations/versions/2020-04-29_09-24_620241d1153f_update_time_grain_sqla.py @@ -74,7 +74,7 @@ def duration_by_name(database: Database): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) query = ( session.query(Slice, Database) diff --git a/superset/migrations/versions/2020-08-12_00-24_978245563a02_migrate_iframe_to_dash_markdown.py b/superset/migrations/versions/2020-08-12_00-24_978245563a02_migrate_iframe_to_dash_markdown.py index 75bae7e47ec1..0628e49fdf92 100644 --- a/superset/migrations/versions/2020-08-12_00-24_978245563a02_migrate_iframe_to_dash_markdown.py +++ b/superset/migrations/versions/2020-08-12_00-24_978245563a02_migrate_iframe_to_dash_markdown.py @@ -89,7 +89,7 @@ def create_new_markdown_component(chart_position, url): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dash_to_migrate = defaultdict(list) iframe_urls = defaultdict(list) diff --git a/superset/migrations/versions/2020-09-24_12-04_3fbbc6e8d654_fix_data_access_permissions_for_virtual_.py b/superset/migrations/versions/2020-09-24_12-04_3fbbc6e8d654_fix_data_access_permissions_for_virtual_.py index 8a72975efc50..717385260b70 100644 --- a/superset/migrations/versions/2020-09-24_12-04_3fbbc6e8d654_fix_data_access_permissions_for_virtual_.py +++ b/superset/migrations/versions/2020-09-24_12-04_3fbbc6e8d654_fix_data_access_permissions_for_virtual_.py @@ -152,7 +152,7 @@ def upgrade(): # noqa: C901 """ bind = op.get_bind() - session = orm.Session(bind=bind, future=True) + session = orm.Session(bind=bind) faulty_view_menus = ( session.query(ViewMenu) diff --git a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py index 7ab8a90cdb17..6ba2d92f0d93 100644 --- a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py +++ b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py @@ -119,7 +119,7 @@ def update_dashboards(session, uuid_map): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for table_name, model in models.items(): with op.batch_alter_table(table_name) as batch_op: @@ -152,7 +152,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # remove uuid from position_json update_dashboards(session, {}) diff --git a/superset/migrations/versions/2020-10-05_18-10_af30ca79208f_collapse_alerting_models_into_a_single_.py b/superset/migrations/versions/2020-10-05_18-10_af30ca79208f_collapse_alerting_models_into_a_single_.py index e3d748ed36e6..0cf53ff9a1b4 100644 --- a/superset/migrations/versions/2020-10-05_18-10_af30ca79208f_collapse_alerting_models_into_a_single_.py +++ b/superset/migrations/versions/2020-10-05_18-10_af30ca79208f_collapse_alerting_models_into_a_single_.py @@ -135,7 +135,7 @@ def upgrade(): ), ) # Migrate data - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) alerts = session.query(Alert).all() for a in alerts: if a.sql_observer: @@ -224,7 +224,7 @@ def downgrade(): ) # Migrate data - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) alerts = session.query(Alert).all() for a in alerts: if a.sql: diff --git a/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py b/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py index be9d6ed04894..1a5d1f3814d7 100644 --- a/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py +++ b/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py @@ -56,7 +56,7 @@ class SavedQuery(ImportMixin, Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # Add uuid column try: @@ -86,7 +86,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) # noqa: F841 + session = db.Session(bind=bind) # noqa: F841 # Remove uuid column with op.batch_alter_table("saved_query") as batch_op: diff --git a/superset/migrations/versions/2020-11-20_14-24_e38177dbf641_security_converge_saved_queries.py b/superset/migrations/versions/2020-11-20_14-24_e38177dbf641_security_converge_saved_queries.py index 96a601b71961..bf033c651461 100644 --- a/superset/migrations/versions/2020-11-20_14-24_e38177dbf641_security_converge_saved_queries.py +++ b/superset/migrations/versions/2020-11-20_14-24_e38177dbf641_security_converge_saved_queries.py @@ -93,7 +93,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -107,7 +107,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-11-30_15-25_40f16acf1ba7_security_converge_reports.py b/superset/migrations/versions/2020-11-30_15-25_40f16acf1ba7_security_converge_reports.py index 7c26ca9fb25d..4535b793b361 100644 --- a/superset/migrations/versions/2020-11-30_15-25_40f16acf1ba7_security_converge_reports.py +++ b/superset/migrations/versions/2020-11-30_15-25_40f16acf1ba7_security_converge_reports.py @@ -65,7 +65,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -79,7 +79,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-11-30_17-54_8ee129739cf9_security_converge_css_templates.py b/superset/migrations/versions/2020-11-30_17-54_8ee129739cf9_security_converge_css_templates.py index 1f472aea3f5c..7a57de742851 100644 --- a/superset/migrations/versions/2020-11-30_17-54_8ee129739cf9_security_converge_css_templates.py +++ b/superset/migrations/versions/2020-11-30_17-54_8ee129739cf9_security_converge_css_templates.py @@ -77,7 +77,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -91,7 +91,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-09_14-13_ccb74baaa89b_security_converge_charts.py b/superset/migrations/versions/2020-12-09_14-13_ccb74baaa89b_security_converge_charts.py index 79fc0839bb74..7697b4981c16 100644 --- a/superset/migrations/versions/2020-12-09_14-13_ccb74baaa89b_security_converge_charts.py +++ b/superset/migrations/versions/2020-12-09_14-13_ccb74baaa89b_security_converge_charts.py @@ -101,7 +101,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -115,7 +115,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-10_15-05_45731db65d9c_security_converge_datasets.py b/superset/migrations/versions/2020-12-10_15-05_45731db65d9c_security_converge_datasets.py index a2289320bf0f..645ee7e58f8b 100644 --- a/superset/migrations/versions/2020-12-10_15-05_45731db65d9c_security_converge_datasets.py +++ b/superset/migrations/versions/2020-12-10_15-05_45731db65d9c_security_converge_datasets.py @@ -87,7 +87,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -101,7 +101,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-11_11-45_1f6dca87d1a2_security_converge_dashboards.py b/superset/migrations/versions/2020-12-11_11-45_1f6dca87d1a2_security_converge_dashboards.py index e85efeb34863..e72fb416e225 100644 --- a/superset/migrations/versions/2020-12-11_11-45_1f6dca87d1a2_security_converge_dashboards.py +++ b/superset/migrations/versions/2020-12-11_11-45_1f6dca87d1a2_security_converge_dashboards.py @@ -101,7 +101,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -115,7 +115,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-11_17-02_c25cb2c78727_security_converge_annotations.py b/superset/migrations/versions/2020-12-11_17-02_c25cb2c78727_security_converge_annotations.py index d85241aa2c33..eedc721c9878 100644 --- a/superset/migrations/versions/2020-12-11_17-02_c25cb2c78727_security_converge_annotations.py +++ b/superset/migrations/versions/2020-12-11_17-02_c25cb2c78727_security_converge_annotations.py @@ -89,7 +89,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -103,7 +103,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-14_10-49_42b4c9e01447_security_converge_databases.py b/superset/migrations/versions/2020-12-14_10-49_42b4c9e01447_security_converge_databases.py index 2de44b0d477e..a56a514a4b3b 100644 --- a/superset/migrations/versions/2020-12-14_10-49_42b4c9e01447_security_converge_databases.py +++ b/superset/migrations/versions/2020-12-14_10-49_42b4c9e01447_security_converge_databases.py @@ -80,7 +80,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -94,7 +94,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-14_13-40_4b84f97828aa_security_converge_logs.py b/superset/migrations/versions/2020-12-14_13-40_4b84f97828aa_security_converge_logs.py index 4ecd41d2bd74..284b7f7525e3 100644 --- a/superset/migrations/versions/2020-12-14_13-40_4b84f97828aa_security_converge_logs.py +++ b/superset/migrations/versions/2020-12-14_13-40_4b84f97828aa_security_converge_logs.py @@ -55,7 +55,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -69,7 +69,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2020-12-16_12-15_e37912a26567_security_converge_queries.py b/superset/migrations/versions/2020-12-16_12-15_e37912a26567_security_converge_queries.py index 788ff84b125a..8c2b1b6c5dff 100644 --- a/superset/migrations/versions/2020-12-16_12-15_e37912a26567_security_converge_queries.py +++ b/superset/migrations/versions/2020-12-16_12-15_e37912a26567_security_converge_queries.py @@ -47,7 +47,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -61,7 +61,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2021-01-23_16-25_260bf0649a77_migrate_x_dateunit_in_time_range.py b/superset/migrations/versions/2021-01-23_16-25_260bf0649a77_migrate_x_dateunit_in_time_range.py index 9158de7804cb..5899b5230ed6 100644 --- a/superset/migrations/versions/2021-01-23_16-25_260bf0649a77_migrate_x_dateunit_in_time_range.py +++ b/superset/migrations/versions/2021-01-23_16-25_260bf0649a77_migrate_x_dateunit_in_time_range.py @@ -53,7 +53,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) x_dateunit_in_since = DateRangeMigration.x_dateunit_in_since x_dateunit_in_until = DateRangeMigration.x_dateunit_in_until diff --git a/superset/migrations/versions/2021-02-04_09-34_070c043f2fdb_add_granularity_to_charts_where_missing.py b/superset/migrations/versions/2021-02-04_09-34_070c043f2fdb_add_granularity_to_charts_where_missing.py index 6c8fc02e10c0..1ebce2daf69a 100644 --- a/superset/migrations/versions/2021-02-04_09-34_070c043f2fdb_add_granularity_to_charts_where_missing.py +++ b/superset/migrations/versions/2021-02-04_09-34_070c043f2fdb_add_granularity_to_charts_where_missing.py @@ -74,7 +74,7 @@ def upgrade(): - If no dttm columns exist in the dataset, don't change the chart. """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices_changed = 0 diff --git a/superset/migrations/versions/2021-02-10_12-32_41ce8799acc3_rename_pie_label_type.py b/superset/migrations/versions/2021-02-10_12-32_41ce8799acc3_rename_pie_label_type.py index 5c5a8cedd020..7e5de7cab16a 100644 --- a/superset/migrations/versions/2021-02-10_12-32_41ce8799acc3_rename_pie_label_type.py +++ b/superset/migrations/versions/2021-02-10_12-32_41ce8799acc3_rename_pie_label_type.py @@ -47,7 +47,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = ( session.query(Slice) @@ -75,7 +75,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = ( session.query(Slice) diff --git a/superset/migrations/versions/2021-02-14_11-46_1412ec1e5a7b_legacy_force_directed_to_echart.py b/superset/migrations/versions/2021-02-14_11-46_1412ec1e5a7b_legacy_force_directed_to_echart.py index 382a85e3b836..5111d8f5a0b2 100644 --- a/superset/migrations/versions/2021-02-14_11-46_1412ec1e5a7b_legacy_force_directed_to_echart.py +++ b/superset/migrations/versions/2021-02-14_11-46_1412ec1e5a7b_legacy_force_directed_to_echart.py @@ -46,7 +46,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type.like("directed_force")): params = json.loads(slc.params) @@ -75,7 +75,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type.like("graph_chart")): params = json.loads(slc.params) diff --git a/superset/migrations/versions/2021-02-18_09-13_c501b7c653a3_add_missing_uuid_column.py b/superset/migrations/versions/2021-02-18_09-13_c501b7c653a3_add_missing_uuid_column.py index aa68490812d2..e8568737ae17 100644 --- a/superset/migrations/versions/2021-02-18_09-13_c501b7c653a3_add_missing_uuid_column.py +++ b/superset/migrations/versions/2021-02-18_09-13_c501b7c653a3_add_missing_uuid_column.py @@ -62,7 +62,7 @@ def has_uuid_column(table_name, bind): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for table_name, model in models.items(): # this script adds missing uuid columns diff --git a/superset/migrations/versions/2021-03-24_09-47_989bbe479899_rename_filter_configuration_in_.py b/superset/migrations/versions/2021-03-24_09-47_989bbe479899_rename_filter_configuration_in_.py index 5cc03f23f546..2452a1db0a6d 100644 --- a/superset/migrations/versions/2021-03-24_09-47_989bbe479899_rename_filter_configuration_in_.py +++ b/superset/migrations/versions/2021-03-24_09-47_989bbe479899_rename_filter_configuration_in_.py @@ -46,7 +46,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) @@ -74,7 +74,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) diff --git a/superset/migrations/versions/2021-04-07_07-21_134cea61c5e7_remove_dataset_health_check_message.py b/superset/migrations/versions/2021-04-07_07-21_134cea61c5e7_remove_dataset_health_check_message.py index 5a4a2f800908..db95c5e95274 100644 --- a/superset/migrations/versions/2021-04-07_07-21_134cea61c5e7_remove_dataset_health_check_message.py +++ b/superset/migrations/versions/2021-04-07_07-21_134cea61c5e7_remove_dataset_health_check_message.py @@ -47,7 +47,7 @@ class SqlaTable(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for datasource in session.query(SqlaTable): if datasource.extra: diff --git a/superset/migrations/versions/2021-04-09_16-14_085f06488938_country_map_use_lowercase_country_name.py b/superset/migrations/versions/2021-04-09_16-14_085f06488938_country_map_use_lowercase_country_name.py index 471072d78e81..8808f9c7a04b 100644 --- a/superset/migrations/versions/2021-04-09_16-14_085f06488938_country_map_use_lowercase_country_name.py +++ b/superset/migrations/versions/2021-04-09_16-14_085f06488938_country_map_use_lowercase_country_name.py @@ -49,7 +49,7 @@ def upgrade(): Convert all country names to lowercase """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "country_map").all(): try: @@ -69,7 +69,7 @@ def downgrade(): Convert all country names to sentence case """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "country_map").all(): try: diff --git a/superset/migrations/versions/2021-04-12_12-38_fc3a3a8ff221_migrate_filter_sets_to_new_format.py b/superset/migrations/versions/2021-04-12_12-38_fc3a3a8ff221_migrate_filter_sets_to_new_format.py index 077dfe53d76f..ed8a4cf5cdd5 100644 --- a/superset/migrations/versions/2021-04-12_12-38_fc3a3a8ff221_migrate_filter_sets_to_new_format.py +++ b/superset/migrations/versions/2021-04-12_12-38_fc3a3a8ff221_migrate_filter_sets_to_new_format.py @@ -172,7 +172,7 @@ def downgrade_filter_set(filter_set: dict[str, Any]) -> int: def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) @@ -208,7 +208,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) diff --git a/superset/migrations/versions/2021-04-29_15-32_f1410ed7ec95_migrate_native_filters_to_new_schema.py b/superset/migrations/versions/2021-04-29_15-32_f1410ed7ec95_migrate_native_filters_to_new_schema.py index 66cc5c4ae80c..a6ed50883b2e 100644 --- a/superset/migrations/versions/2021-04-29_15-32_f1410ed7ec95_migrate_native_filters_to_new_schema.py +++ b/superset/migrations/versions/2021-04-29_15-32_f1410ed7ec95_migrate_native_filters_to_new_schema.py @@ -94,7 +94,7 @@ def upgrade_dashboard(dashboard: dict[str, Any]) -> tuple[int, int]: def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) @@ -136,7 +136,7 @@ def downgrade_dashboard(dashboard: dict[str, Any]) -> tuple[int, int]: def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) diff --git a/superset/migrations/versions/2021-08-02_16-39_e323605f370a_fix_schemas_allowed_for_csv_upload.py b/superset/migrations/versions/2021-08-02_16-39_e323605f370a_fix_schemas_allowed_for_csv_upload.py index 046d3b22e60b..3862c247a7a7 100644 --- a/superset/migrations/versions/2021-08-02_16-39_e323605f370a_fix_schemas_allowed_for_csv_upload.py +++ b/superset/migrations/versions/2021-08-02_16-39_e323605f370a_fix_schemas_allowed_for_csv_upload.py @@ -52,7 +52,7 @@ def upgrade(): Fix databases with ``schemas_allowed_for_csv_upload`` stored as string. """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for database in session.query(Database).all(): try: diff --git a/superset/migrations/versions/2021-08-03_15-36_143b6f2815da_migrate_pivot_table_v2_heatmaps_to_new_.py b/superset/migrations/versions/2021-08-03_15-36_143b6f2815da_migrate_pivot_table_v2_heatmaps_to_new_.py index 96da91cb4634..093eb0c08cc7 100644 --- a/superset/migrations/versions/2021-08-03_15-36_143b6f2815da_migrate_pivot_table_v2_heatmaps_to_new_.py +++ b/superset/migrations/versions/2021-08-03_15-36_143b6f2815da_migrate_pivot_table_v2_heatmaps_to_new_.py @@ -56,7 +56,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = ( session.query(Slice) diff --git a/superset/migrations/versions/2021-08-04_17-16_f6196627326f_update_chart_permissions.py b/superset/migrations/versions/2021-08-04_17-16_f6196627326f_update_chart_permissions.py index 778dbf70f0c5..9a24138cef8b 100644 --- a/superset/migrations/versions/2021-08-04_17-16_f6196627326f_update_chart_permissions.py +++ b/superset/migrations/versions/2021-08-04_17-16_f6196627326f_update_chart_permissions.py @@ -47,7 +47,7 @@ def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the new permissions on the migration itself add_pvms(session, NEW_PVMS) @@ -61,7 +61,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) # Add the old permissions on the migration itself add_pvms(session, get_reversed_new_pvms(PVM_MAP)) diff --git a/superset/migrations/versions/2021-08-09_17-32_07071313dd52_change_fetch_values_predicate_to_text.py b/superset/migrations/versions/2021-08-09_17-32_07071313dd52_change_fetch_values_predicate_to_text.py index 7216d86baf58..5af0d88e1856 100644 --- a/superset/migrations/versions/2021-08-09_17-32_07071313dd52_change_fetch_values_predicate_to_text.py +++ b/superset/migrations/versions/2021-08-09_17-32_07071313dd52_change_fetch_values_predicate_to_text.py @@ -50,7 +50,7 @@ def upgrade(): def remove_value_if_too_long(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) # it will be easier for users to notice that their field has been deleted rather than truncated # noqa: E501 # so just remove it if it won't fit back into the 1000 string length column diff --git a/superset/migrations/versions/2021-08-31_11-37_021b81fe4fbb_add_type_to_native_filter_configuration.py b/superset/migrations/versions/2021-08-31_11-37_021b81fe4fbb_add_type_to_native_filter_configuration.py index c1bedf38d8ae..7a28cf456742 100644 --- a/superset/migrations/versions/2021-08-31_11-37_021b81fe4fbb_add_type_to_native_filter_configuration.py +++ b/superset/migrations/versions/2021-08-31_11-37_021b81fe4fbb_add_type_to_native_filter_configuration.py @@ -49,7 +49,7 @@ class Dashboard(Base): def upgrade(): logger.info("[AddTypeToNativeFilter] Starting upgrade") bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in session.query(Dashboard).all(): logger.info("[AddTypeToNativeFilter] Updating Dashboard ", dashboard.id) @@ -87,7 +87,7 @@ def upgrade(): def downgrade(): logger.info("[RemoveTypeToNativeFilter] Starting downgrade") bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in session.query(Dashboard).all(): logger.info( diff --git a/superset/migrations/versions/2021-09-27_11-31_60dc453f4e2e_migrate_timeseries_limit_metric_to_.py b/superset/migrations/versions/2021-09-27_11-31_60dc453f4e2e_migrate_timeseries_limit_metric_to_.py index 41e2f7f2c017..5d149c7efda8 100644 --- a/superset/migrations/versions/2021-09-27_11-31_60dc453f4e2e_migrate_timeseries_limit_metric_to_.py +++ b/superset/migrations/versions/2021-09-27_11-31_60dc453f4e2e_migrate_timeseries_limit_metric_to_.py @@ -47,7 +47,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) where_clause = and_( Slice.viz_type == "pivot_table_v2", diff --git a/superset/migrations/versions/2021-10-12_11-15_32646df09c64_update_time_grain_sqla.py b/superset/migrations/versions/2021-10-12_11-15_32646df09c64_update_time_grain_sqla.py index 96a6591926df..e881e64d084c 100644 --- a/superset/migrations/versions/2021-10-12_11-15_32646df09c64_update_time_grain_sqla.py +++ b/superset/migrations/versions/2021-10-12_11-15_32646df09c64_update_time_grain_sqla.py @@ -45,7 +45,7 @@ class Slice(Base): def migrate(mapping: dict[str, str]) -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): try: diff --git a/superset/migrations/versions/2021-11-11_04-18_0ca9e5f1dacd_rename_to_schemas_allowed_for_file_.py b/superset/migrations/versions/2021-11-11_04-18_0ca9e5f1dacd_rename_to_schemas_allowed_for_file_.py index 9e8089eb5cef..fff54a88c24a 100644 --- a/superset/migrations/versions/2021-11-11_04-18_0ca9e5f1dacd_rename_to_schemas_allowed_for_file_.py +++ b/superset/migrations/versions/2021-11-11_04-18_0ca9e5f1dacd_rename_to_schemas_allowed_for_file_.py @@ -48,7 +48,7 @@ class Database(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for database in session.query(Database).all(): try: @@ -70,7 +70,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for database in session.query(Database).all(): try: diff --git a/superset/migrations/versions/2021-12-10_19-25_bb38f40aa3ff_add_force_screenshot_to_alerts_reports.py b/superset/migrations/versions/2021-12-10_19-25_bb38f40aa3ff_add_force_screenshot_to_alerts_reports.py index aeb190517048..adea3faf9bc8 100644 --- a/superset/migrations/versions/2021-12-10_19-25_bb38f40aa3ff_add_force_screenshot_to_alerts_reports.py +++ b/superset/migrations/versions/2021-12-10_19-25_bb38f40aa3ff_add_force_screenshot_to_alerts_reports.py @@ -49,7 +49,7 @@ def upgrade(): batch_op.add_column(sa.Column("force_screenshot", sa.Boolean(), default=False)) bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for report in session.query(ReportSchedule).all(): # Update existing alerts that send chart screenshots so that the cache is diff --git a/superset/migrations/versions/2021-12-13_14-06_fe23025b9441_rename_big_viz_total_form_data_fields.py b/superset/migrations/versions/2021-12-13_14-06_fe23025b9441_rename_big_viz_total_form_data_fields.py index 01aa006428be..26eb3c0d71fd 100644 --- a/superset/migrations/versions/2021-12-13_14-06_fe23025b9441_rename_big_viz_total_form_data_fields.py +++ b/superset/migrations/versions/2021-12-13_14-06_fe23025b9441_rename_big_viz_total_form_data_fields.py @@ -50,7 +50,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type == "big_number_total").all() for slc in slices: @@ -77,7 +77,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type == "big_number_total").all() for slc in slices: diff --git a/superset/migrations/versions/2021-12-17_16-56_31bb738bd1d2_move_pivot_table_v2_legacy_order_by_to_.py b/superset/migrations/versions/2021-12-17_16-56_31bb738bd1d2_move_pivot_table_v2_legacy_order_by_to_.py index f8a9dea5945f..776441422da1 100644 --- a/superset/migrations/versions/2021-12-17_16-56_31bb738bd1d2_move_pivot_table_v2_legacy_order_by_to_.py +++ b/superset/migrations/versions/2021-12-17_16-56_31bb738bd1d2_move_pivot_table_v2_legacy_order_by_to_.py @@ -51,7 +51,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type == "pivot_table_v2").all() for slc in slices: @@ -75,7 +75,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type == "pivot_table_v2").all() for slc in slices: diff --git a/superset/migrations/versions/2022-03-02_09-20_b5a422d8e252_fix_query_and_saved_query_null_schema.py b/superset/migrations/versions/2022-03-02_09-20_b5a422d8e252_fix_query_and_saved_query_null_schema.py index 8930ba7e6731..bfb4e97b04e5 100644 --- a/superset/migrations/versions/2022-03-02_09-20_b5a422d8e252_fix_query_and_saved_query_null_schema.py +++ b/superset/migrations/versions/2022-03-02_09-20_b5a422d8e252_fix_query_and_saved_query_null_schema.py @@ -51,7 +51,7 @@ class SavedQuery(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for model in (Query, SavedQuery): for record in session.query(model).filter(model.schema == "null"): diff --git a/superset/migrations/versions/2022-03-02_16-41_7293b0ca7944_change_adhoc_filter_b_from_none_to_.py b/superset/migrations/versions/2022-03-02_16-41_7293b0ca7944_change_adhoc_filter_b_from_none_to_.py index 2904d49dbc94..e8779e5d83e7 100644 --- a/superset/migrations/versions/2022-03-02_16-41_7293b0ca7944_change_adhoc_filter_b_from_none_to_.py +++ b/superset/migrations/versions/2022-03-02_16-41_7293b0ca7944_change_adhoc_filter_b_from_none_to_.py @@ -47,7 +47,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "mixed_timeseries").all(): try: @@ -66,7 +66,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "mixed_timeseries").all(): try: diff --git a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py index 93962991b75a..492c85c8e93e 100644 --- a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py +++ b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py @@ -894,7 +894,7 @@ def reset_postgres_id_sequence(table: str) -> None: def upgrade() -> None: bind = op.get_bind() - session: Session = Session(bind=bind, future=True) + session: Session = Session(bind=bind) Base.metadata.drop_all(bind=bind, tables=new_tables) Base.metadata.create_all(bind=bind, tables=new_tables) diff --git a/superset/migrations/versions/2022-04-04_15-04_b0d0249074e4_deprecate_time_range_endpoints_v2.py b/superset/migrations/versions/2022-04-04_15-04_b0d0249074e4_deprecate_time_range_endpoints_v2.py index 51f88a999a92..bbc92fee108f 100644 --- a/superset/migrations/versions/2022-04-04_15-04_b0d0249074e4_deprecate_time_range_endpoints_v2.py +++ b/superset/migrations/versions/2022-04-04_15-04_b0d0249074e4_deprecate_time_range_endpoints_v2.py @@ -44,7 +44,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.params.like("%time_range_endpoints%")): params = json.loads(slc.params) diff --git a/superset/migrations/versions/2022-04-18_11-20_ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py b/superset/migrations/versions/2022-04-18_11-20_ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py index 5c50e30157e4..7671b1b665d5 100644 --- a/superset/migrations/versions/2022-04-18_11-20_ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py +++ b/superset/migrations/versions/2022-04-18_11-20_ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py @@ -63,7 +63,7 @@ def upgrade_slice(slc: Slice): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices_updated = 0 for slc in ( session.query(Slice) diff --git a/superset/migrations/versions/2022-05-03_19-39_cbe71abde154_fix_report_schedule_and_log.py b/superset/migrations/versions/2022-05-03_19-39_cbe71abde154_fix_report_schedule_and_log.py index abfff3c57766..5fde75de161a 100644 --- a/superset/migrations/versions/2022-05-03_19-39_cbe71abde154_fix_report_schedule_and_log.py +++ b/superset/migrations/versions/2022-05-03_19-39_cbe71abde154_fix_report_schedule_and_log.py @@ -56,7 +56,7 @@ class ReportSchedule(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for schedule in ( session.query(ReportSchedule) diff --git a/superset/migrations/versions/2022-05-18_16-07_e786798587de_delete_none_permissions.py b/superset/migrations/versions/2022-05-18_16-07_e786798587de_delete_none_permissions.py index c5f68248e693..6a3d4acbe62d 100644 --- a/superset/migrations/versions/2022-05-18_16-07_e786798587de_delete_none_permissions.py +++ b/superset/migrations/versions/2022-05-18_16-07_e786798587de_delete_none_permissions.py @@ -98,7 +98,7 @@ def __repr__(self) -> str: def upgrade(): # ### commands auto generated by Alembic - please adjust! ### bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) pvms = ( session.query(PermissionView) diff --git a/superset/migrations/versions/2022-06-19_16-17_f3afaf1f11f0_add_unique_name_desc_rls.py b/superset/migrations/versions/2022-06-19_16-17_f3afaf1f11f0_add_unique_name_desc_rls.py index 035ca511db49..1d8389bcc831 100644 --- a/superset/migrations/versions/2022-06-19_16-17_f3afaf1f11f0_add_unique_name_desc_rls.py +++ b/superset/migrations/versions/2022-06-19_16-17_f3afaf1f11f0_add_unique_name_desc_rls.py @@ -42,7 +42,7 @@ class RowLevelSecurityFilter(Base): def upgrade(): # ### commands auto generated by Alembic - please adjust! ### bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) op.add_column( "row_level_security_filters", sa.Column("name", sa.String(length=255)) diff --git a/superset/migrations/versions/2022-06-27_14-59_7fb8bca906d2_permalink_rename_filterstate.py b/superset/migrations/versions/2022-06-27_14-59_7fb8bca906d2_permalink_rename_filterstate.py index 0b90fd745997..1608e72afdc5 100644 --- a/superset/migrations/versions/2022-06-27_14-59_7fb8bca906d2_permalink_rename_filterstate.py +++ b/superset/migrations/versions/2022-06-27_14-59_7fb8bca906d2_permalink_rename_filterstate.py @@ -49,7 +49,7 @@ class KeyValueEntry(Base): def upgrade(): bind = op.get_bind() - session: Session = db.Session(bind=bind, future=True) + session: Session = db.Session(bind=bind) for entry in paginated_update( session.query(KeyValueEntry).filter( KeyValueEntry.resource == DASHBOARD_PERMALINK_RESOURCE_TYPE @@ -69,7 +69,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session: Session = db.Session(bind=bind, future=True) + session: Session = db.Session(bind=bind) for entry in paginated_update( session.query(KeyValueEntry).filter( KeyValueEntry.resource == DASHBOARD_PERMALINK_RESOURCE_TYPE diff --git a/superset/migrations/versions/2022-07-05_15-48_409c7b420ab0_add_created_by_fk_as_owner.py b/superset/migrations/versions/2022-07-05_15-48_409c7b420ab0_add_created_by_fk_as_owner.py index 246d5a601535..d5c5d9887011 100644 --- a/superset/migrations/versions/2022-07-05_15-48_409c7b420ab0_add_created_by_fk_as_owner.py +++ b/superset/migrations/versions/2022-07-05_15-48_409c7b420ab0_add_created_by_fk_as_owner.py @@ -83,7 +83,7 @@ class SqlaTableUser(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) op.execute( insert(DatasetUser).from_select( diff --git a/superset/migrations/versions/2022-07-07_13-00_c747c78868b6_migrating_legacy_treemap.py b/superset/migrations/versions/2022-07-07_13-00_c747c78868b6_migrating_legacy_treemap.py index 4b4ea772a090..66b12da3459e 100644 --- a/superset/migrations/versions/2022-07-07_13-00_c747c78868b6_migrating_legacy_treemap.py +++ b/superset/migrations/versions/2022-07-07_13-00_c747c78868b6_migrating_legacy_treemap.py @@ -45,11 +45,11 @@ def upgrade(): op.execute(text("ALTER TABLE slices MODIFY params MEDIUMTEXT")) op.execute(text("ALTER TABLE slices MODIFY query_context MEDIUMTEXT")) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateTreeMap.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateTreeMap.downgrade(session) diff --git a/superset/migrations/versions/2022-07-07_14-00_06e1e70058c7_migrating_legacy_area.py b/superset/migrations/versions/2022-07-07_14-00_06e1e70058c7_migrating_legacy_area.py index b3b28e1ee22c..adeaabac0caf 100644 --- a/superset/migrations/versions/2022-07-07_14-00_06e1e70058c7_migrating_legacy_area.py +++ b/superset/migrations/versions/2022-07-07_14-00_06e1e70058c7_migrating_legacy_area.py @@ -34,11 +34,11 @@ def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateAreaChart.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateAreaChart.downgrade(session) diff --git a/superset/migrations/versions/2022-08-16_15-23_6d3c6f9d665d_fix_table_chart_conditional_formatting_.py b/superset/migrations/versions/2022-08-16_15-23_6d3c6f9d665d_fix_table_chart_conditional_formatting_.py index d2f1ab68a229..aa81c46b3a26 100644 --- a/superset/migrations/versions/2022-08-16_15-23_6d3c6f9d665d_fix_table_chart_conditional_formatting_.py +++ b/superset/migrations/versions/2022-08-16_15-23_6d3c6f9d665d_fix_table_chart_conditional_formatting_.py @@ -45,7 +45,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == "table"): params = json.loads(slc.params) diff --git a/superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py b/superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py index 81a5e83a7216..4b390139f73f 100644 --- a/superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py +++ b/superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py @@ -48,7 +48,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) dashboards = ( session.query(Dashboard) diff --git a/superset/migrations/versions/2023-02-28_14-46_c0a3ea245b61_remove_show_native_filters.py b/superset/migrations/versions/2023-02-28_14-46_c0a3ea245b61_remove_show_native_filters.py index ed3e3b0340a1..ad9ff0585c7f 100644 --- a/superset/migrations/versions/2023-02-28_14-46_c0a3ea245b61_remove_show_native_filters.py +++ b/superset/migrations/versions/2023-02-28_14-46_c0a3ea245b61_remove_show_native_filters.py @@ -45,7 +45,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in session.query(Dashboard).all(): try: diff --git a/superset/migrations/versions/2023-03-05_10-06_d0ac08bb5b83_invert_horizontal_bar_chart_order.py b/superset/migrations/versions/2023-03-05_10-06_d0ac08bb5b83_invert_horizontal_bar_chart_order.py index f0dd0c77bbd5..949d67754382 100644 --- a/superset/migrations/versions/2023-03-05_10-06_d0ac08bb5b83_invert_horizontal_bar_chart_order.py +++ b/superset/migrations/versions/2023-03-05_10-06_d0ac08bb5b83_invert_horizontal_bar_chart_order.py @@ -50,7 +50,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = ( session.query(Slice) @@ -88,7 +88,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = ( session.query(Slice) diff --git a/superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py b/superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py index bff01696a0e1..652fc542dc82 100644 --- a/superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py +++ b/superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py @@ -49,7 +49,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type.like(CHART_TYPE)).all() for slc in slices: @@ -72,7 +72,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) slices = session.query(Slice).filter(Slice.viz_type.like(CHART_TYPE)).all() for slc in slices: diff --git a/superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py b/superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py index ed7bc1792abe..1790ea512f26 100644 --- a/superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py +++ b/superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py @@ -83,7 +83,7 @@ def upgrade_slc(slc: Slice) -> None: def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) with op.batch_alter_table("slices") as batch_op: for slc in session.query(Slice).filter(Slice.datasource_type != "table").all(): if slc.datasource_type == "query": diff --git a/superset/migrations/versions/2023-05-01_12-03_9c2a5681ddfd_convert_key_value_entries_to_json.py b/superset/migrations/versions/2023-05-01_12-03_9c2a5681ddfd_convert_key_value_entries_to_json.py index 61466a859633..58b89cffceac 100644 --- a/superset/migrations/versions/2023-05-01_12-03_9c2a5681ddfd_convert_key_value_entries_to_json.py +++ b/superset/migrations/versions/2023-05-01_12-03_9c2a5681ddfd_convert_key_value_entries_to_json.py @@ -59,7 +59,7 @@ class KeyValueEntry(Base): def upgrade(): bind = op.get_bind() - session: Session = db.Session(bind=bind, future=True) + session: Session = db.Session(bind=bind) truncated_count = 0 for entry in paginated_update( session.query(KeyValueEntry).filter( @@ -85,7 +85,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session: Session = db.Session(bind=bind, future=True) + session: Session = db.Session(bind=bind) for entry in paginated_update( session.query(KeyValueEntry).filter( KeyValueEntry.resource.in_(RESOURCES_TO_MIGRATE) diff --git a/superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py b/superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py index 51972619d28a..1d4322805a7a 100644 --- a/superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py +++ b/superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py @@ -50,7 +50,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in paginated_update(session.query(Dashboard)): # # This is needed in order to work-around a potential issue @@ -100,7 +100,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in paginated_update(session.query(Dashboard)): try: diff --git a/superset/migrations/versions/2023-06-08_09-02_9ba2ce3086e5_migrate_pivot_table_v1_to_v2.py b/superset/migrations/versions/2023-06-08_09-02_9ba2ce3086e5_migrate_pivot_table_v1_to_v2.py index cffb1ca744f8..f7c7a63ae682 100644 --- a/superset/migrations/versions/2023-06-08_09-02_9ba2ce3086e5_migrate_pivot_table_v1_to_v2.py +++ b/superset/migrations/versions/2023-06-08_09-02_9ba2ce3086e5_migrate_pivot_table_v1_to_v2.py @@ -34,11 +34,11 @@ def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigratePivotTable.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigratePivotTable.downgrade(session) diff --git a/superset/migrations/versions/2023-06-08_10-22_4c5da39be729_migrate_treemap_chart.py b/superset/migrations/versions/2023-06-08_10-22_4c5da39be729_migrate_treemap_chart.py index 9092ba5e15e5..5a33ba0c3902 100644 --- a/superset/migrations/versions/2023-06-08_10-22_4c5da39be729_migrate_treemap_chart.py +++ b/superset/migrations/versions/2023-06-08_10-22_4c5da39be729_migrate_treemap_chart.py @@ -45,11 +45,11 @@ def upgrade(): op.execute(text("ALTER TABLE slices MODIFY params MEDIUMTEXT")) op.execute(text("ALTER TABLE slices MODIFY query_context MEDIUMTEXT")) - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateTreeMap.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateTreeMap.downgrade(session) diff --git a/superset/migrations/versions/2023-06-08_11-34_ae58e1e58e5c_migrate_dual_line_to_mixed_chart.py b/superset/migrations/versions/2023-06-08_11-34_ae58e1e58e5c_migrate_dual_line_to_mixed_chart.py index b529ea906bf7..dc8e068af9c2 100644 --- a/superset/migrations/versions/2023-06-08_11-34_ae58e1e58e5c_migrate_dual_line_to_mixed_chart.py +++ b/superset/migrations/versions/2023-06-08_11-34_ae58e1e58e5c_migrate_dual_line_to_mixed_chart.py @@ -36,11 +36,11 @@ def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateDualLine.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateDualLine.downgrade(session) diff --git a/superset/migrations/versions/2023-07-18_15-30_863adcf72773_delete_obsolete_druid_nosql_slice_parameters.py b/superset/migrations/versions/2023-07-18_15-30_863adcf72773_delete_obsolete_druid_nosql_slice_parameters.py index e0801d0eca02..5b9e4272068e 100644 --- a/superset/migrations/versions/2023-07-18_15-30_863adcf72773_delete_obsolete_druid_nosql_slice_parameters.py +++ b/superset/migrations/versions/2023-07-18_15-30_863adcf72773_delete_obsolete_druid_nosql_slice_parameters.py @@ -48,7 +48,7 @@ class Slice(Base): def upgrade(): # noqa: C901 bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.params: diff --git a/superset/migrations/versions/2023-07-19_16-48_a23c6f8b1280_cleanup_erroneous_parent_filter_ids.py b/superset/migrations/versions/2023-07-19_16-48_a23c6f8b1280_cleanup_erroneous_parent_filter_ids.py index c06093a92f1a..746bd7513be0 100644 --- a/superset/migrations/versions/2023-07-19_16-48_a23c6f8b1280_cleanup_erroneous_parent_filter_ids.py +++ b/superset/migrations/versions/2023-07-19_16-48_a23c6f8b1280_cleanup_erroneous_parent_filter_ids.py @@ -48,7 +48,7 @@ class Dashboard(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for dashboard in session.query(Dashboard).all(): if dashboard.json_metadata: diff --git a/superset/migrations/versions/2023-07-19_17-54_ee179a490af9_deckgl_path_width_units.py b/superset/migrations/versions/2023-07-19_17-54_ee179a490af9_deckgl_path_width_units.py index 16562421e536..744b401bd234 100644 --- a/superset/migrations/versions/2023-07-19_17-54_ee179a490af9_deckgl_path_width_units.py +++ b/superset/migrations/versions/2023-07-19_17-54_ee179a490af9_deckgl_path_width_units.py @@ -48,7 +48,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter( or_( Slice.viz_type == "deck_path", diff --git a/superset/migrations/versions/2023-08-02_15-23_0769ef90fddd_fix_schema_perm_for_datasets.py b/superset/migrations/versions/2023-08-02_15-23_0769ef90fddd_fix_schema_perm_for_datasets.py index 80da4e3ddad6..fefc8f3b11d6 100644 --- a/superset/migrations/versions/2023-08-02_15-23_0769ef90fddd_fix_schema_perm_for_datasets.py +++ b/superset/migrations/versions/2023-08-02_15-23_0769ef90fddd_fix_schema_perm_for_datasets.py @@ -93,7 +93,7 @@ def fix_charts_schema_perm(session): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) if isinstance(bind.dialect, SQLiteDialect): return # sqlite doesn't have a concat function diff --git a/superset/migrations/versions/2023-08-14_09-38_9f4a086c2676_add_normalize_columns_to_sqla_model.py b/superset/migrations/versions/2023-08-14_09-38_9f4a086c2676_add_normalize_columns_to_sqla_model.py index 89b7ba481ac2..3d23c4f0ddf5 100644 --- a/superset/migrations/versions/2023-08-14_09-38_9f4a086c2676_add_normalize_columns_to_sqla_model.py +++ b/superset/migrations/versions/2023-08-14_09-38_9f4a086c2676_add_normalize_columns_to_sqla_model.py @@ -56,7 +56,7 @@ def upgrade(): ) bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for table in paginated_update(session.query(SqlaTable)): table.normalize_columns = True diff --git a/superset/migrations/versions/2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_.py b/superset/migrations/versions/2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_.py index 2ec9e5b88ba4..29fac917bf08 100755 --- a/superset/migrations/versions/2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_.py +++ b/superset/migrations/versions/2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_.py @@ -60,7 +60,7 @@ def upgrade(): ) bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for table in paginated_update(session.query(SqlaTable)): table.always_filter_main_dttm = False diff --git a/superset/migrations/versions/2023-12-15_17-58_06dd9ff00fe8_add_percent_calculation_type_funnel_.py b/superset/migrations/versions/2023-12-15_17-58_06dd9ff00fe8_add_percent_calculation_type_funnel_.py index 266dc7ea8581..b2a4f14c8b64 100644 --- a/superset/migrations/versions/2023-12-15_17-58_06dd9ff00fe8_add_percent_calculation_type_funnel_.py +++ b/superset/migrations/versions/2023-12-15_17-58_06dd9ff00fe8_add_percent_calculation_type_funnel_.py @@ -46,7 +46,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type == "funnel") @@ -61,7 +61,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type == "funnel") diff --git a/superset/migrations/versions/2024-01-18_14-41_a32e0c4d8646_migrate_sunburst_chart.py b/superset/migrations/versions/2024-01-18_14-41_a32e0c4d8646_migrate_sunburst_chart.py index 46badaa34f56..1ed8d4662121 100644 --- a/superset/migrations/versions/2024-01-18_14-41_a32e0c4d8646_migrate_sunburst_chart.py +++ b/superset/migrations/versions/2024-01-18_14-41_a32e0c4d8646_migrate_sunburst_chart.py @@ -34,11 +34,11 @@ def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateSunburst.upgrade(session) def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateSunburst.downgrade(session) diff --git a/superset/migrations/versions/2024-01-18_15-20_214f580d09c9_migrate_filter_boxes_to_native_filters.py b/superset/migrations/versions/2024-01-18_15-20_214f580d09c9_migrate_filter_boxes_to_native_filters.py index ecefe6862fc7..0f72209d55ee 100644 --- a/superset/migrations/versions/2024-01-18_15-20_214f580d09c9_migrate_filter_boxes_to_native_filters.py +++ b/superset/migrations/versions/2024-01-18_15-20_214f580d09c9_migrate_filter_boxes_to_native_filters.py @@ -71,7 +71,7 @@ def __repr__(self) -> str: def upgrade(): - session = db.Session(bind=op.get_bind(), future=True) + session = db.Session(bind=op.get_bind()) for dashboard in paginated_update(session.query(Dashboard)): migrate_dashboard(dashboard) diff --git a/superset/migrations/versions/2024-02-07_17-13_87d38ad83218_migrate_can_view_and_drill_permission.py b/superset/migrations/versions/2024-02-07_17-13_87d38ad83218_migrate_can_view_and_drill_permission.py index 0d014bb77b57..1fc4158357db 100644 --- a/superset/migrations/versions/2024-02-07_17-13_87d38ad83218_migrate_can_view_and_drill_permission.py +++ b/superset/migrations/versions/2024-02-07_17-13_87d38ad83218_migrate_can_view_and_drill_permission.py @@ -60,7 +60,7 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) @@ -73,7 +73,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2024-03-01_10-47_be1b217cd8cd_big_number_kpi_single_metric.py b/superset/migrations/versions/2024-03-01_10-47_be1b217cd8cd_big_number_kpi_single_metric.py index 51cf6b1c5449..8ba0d2c67a09 100644 --- a/superset/migrations/versions/2024-03-01_10-47_be1b217cd8cd_big_number_kpi_single_metric.py +++ b/superset/migrations/versions/2024-03-01_10-47_be1b217cd8cd_big_number_kpi_single_metric.py @@ -48,7 +48,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type == "pop_kpi") @@ -71,7 +71,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type == "pop_kpi") diff --git a/superset/migrations/versions/2024-04-08_15-43_5ad7321c2169_mig_new_csv_upload_perm.py b/superset/migrations/versions/2024-04-08_15-43_5ad7321c2169_mig_new_csv_upload_perm.py index 966721022bb1..e5c0121a1d0b 100644 --- a/superset/migrations/versions/2024-04-08_15-43_5ad7321c2169_mig_new_csv_upload_perm.py +++ b/superset/migrations/versions/2024-04-08_15-43_5ad7321c2169_mig_new_csv_upload_perm.py @@ -60,7 +60,7 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) @@ -73,7 +73,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2024-04-17_14-04_d60591c5515f_mig_new_excel_upload_perm.py b/superset/migrations/versions/2024-04-17_14-04_d60591c5515f_mig_new_excel_upload_perm.py index 76c1ccd71f58..69465d1b8972 100644 --- a/superset/migrations/versions/2024-04-17_14-04_d60591c5515f_mig_new_excel_upload_perm.py +++ b/superset/migrations/versions/2024-04-17_14-04_d60591c5515f_mig_new_excel_upload_perm.py @@ -62,7 +62,7 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) @@ -75,7 +75,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2024-04-26_12-36_4a33124c18ad_mig_new_columnar_upload_perm.py b/superset/migrations/versions/2024-04-26_12-36_4a33124c18ad_mig_new_columnar_upload_perm.py index 3931c9f39a38..57c129db33f0 100644 --- a/superset/migrations/versions/2024-04-26_12-36_4a33124c18ad_mig_new_columnar_upload_perm.py +++ b/superset/migrations/versions/2024-04-26_12-36_4a33124c18ad_mig_new_columnar_upload_perm.py @@ -63,7 +63,7 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) @@ -76,7 +76,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py b/superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py index dd5e1681e778..10d8d82282dc 100644 --- a/superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py +++ b/superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py @@ -97,7 +97,7 @@ def upgrade_comparison_params(slice_params: dict[str, Any]) -> dict[str, Any]: def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter( @@ -198,7 +198,7 @@ def downgrade_comparison_params(slice_params: dict[str, Any]) -> dict[str, Any]: def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter( diff --git a/superset/migrations/versions/2025-01-08_09-34_d482d51c15ca_remove_legacy_plugins_5_0.py b/superset/migrations/versions/2025-01-08_09-34_d482d51c15ca_remove_legacy_plugins_5_0.py index bfb7f10700ec..22b174cf3dc4 100644 --- a/superset/migrations/versions/2025-01-08_09-34_d482d51c15ca_remove_legacy_plugins_5_0.py +++ b/superset/migrations/versions/2025-01-08_09-34_d482d51c15ca_remove_legacy_plugins_5_0.py @@ -42,7 +42,7 @@ def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) try: MigrateAreaChart.upgrade(session) MigrateBarChart.upgrade(session) @@ -61,7 +61,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) try: MigrateAreaChart.downgrade(session) MigrateBarChart.downgrade(session) diff --git a/superset/migrations/versions/2025-01-22_14-34_74ad1125881c_converge_upload_permissions.py b/superset/migrations/versions/2025-01-22_14-34_74ad1125881c_converge_upload_permissions.py index 1dadc9fd850b..75a5e0ad9790 100644 --- a/superset/migrations/versions/2025-01-22_14-34_74ad1125881c_converge_upload_permissions.py +++ b/superset/migrations/versions/2025-01-22_14-34_74ad1125881c_converge_upload_permissions.py @@ -59,7 +59,7 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) @@ -72,7 +72,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2025-04-13_22-10_378cecfdba9f_merge_x_axis_sort_series_with_x_axis_.py b/superset/migrations/versions/2025-04-13_22-10_378cecfdba9f_merge_x_axis_sort_series_with_x_axis_.py index 464aa0e29ea9..1bda3175cdb2 100644 --- a/superset/migrations/versions/2025-04-13_22-10_378cecfdba9f_merge_x_axis_sort_series_with_x_axis_.py +++ b/superset/migrations/versions/2025-04-13_22-10_378cecfdba9f_merge_x_axis_sort_series_with_x_axis_.py @@ -58,7 +58,7 @@ class Slice(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type.in_(timeseries_charts)) ): @@ -87,7 +87,7 @@ def upgrade(): def downgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter(Slice.viz_type.in_(timeseries_charts)) diff --git a/superset/migrations/versions/2025-06-06_00-39_363a9b1e8992_convert_metric_currencies_from_str_to_json.py b/superset/migrations/versions/2025-06-06_00-39_363a9b1e8992_convert_metric_currencies_from_str_to_json.py index 81ba05dbe57a..d4dce03c2b3c 100644 --- a/superset/migrations/versions/2025-06-06_00-39_363a9b1e8992_convert_metric_currencies_from_str_to_json.py +++ b/superset/migrations/versions/2025-06-06_00-39_363a9b1e8992_convert_metric_currencies_from_str_to_json.py @@ -51,7 +51,7 @@ class SqlMetric(Base): def upgrade(): bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) currency_configs = session.query(SqlMetric).filter(SqlMetric.currency.isnot(None)) for metric in paginated_update( currency_configs, diff --git a/superset/migrations/versions/2025-12-16_12-00_f5b5f88d8526_fix_form_data_string_in_query_context.py b/superset/migrations/versions/2025-12-16_12-00_f5b5f88d8526_fix_form_data_string_in_query_context.py index 2b16f370fbb9..dfa3e7e85e28 100644 --- a/superset/migrations/versions/2025-12-16_12-00_f5b5f88d8526_fix_form_data_string_in_query_context.py +++ b/superset/migrations/versions/2025-12-16_12-00_f5b5f88d8526_fix_form_data_string_in_query_context.py @@ -71,7 +71,7 @@ def upgrade(): instead of a dict during chart import migration. """ bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in paginated_update( session.query(Slice).filter( diff --git a/superset/migrations/versions/2026-03-02_00-00_ce6bd21901ab_migrate_deckgl_and_mapbox.py b/superset/migrations/versions/2026-03-02_00-00_ce6bd21901ab_migrate_deckgl_and_mapbox.py index d78602acaf45..0ee521d4b8b0 100644 --- a/superset/migrations/versions/2026-03-02_00-00_ce6bd21901ab_migrate_deckgl_and_mapbox.py +++ b/superset/migrations/versions/2026-03-02_00-00_ce6bd21901ab_migrate_deckgl_and_mapbox.py @@ -206,13 +206,13 @@ def _migrate_deckgl_slices(session: Session, *, upgrade: bool) -> None: def upgrade() -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateMapBox.upgrade(session) _migrate_deckgl_slices(session, upgrade=True) def downgrade() -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) MigrateMapBox.downgrade(session) _migrate_deckgl_slices(session, upgrade=False) diff --git a/superset/migrations/versions/2026-03-02_12-00_a1b2c3d4e5f6_add_granular_export_permissions.py b/superset/migrations/versions/2026-03-02_12-00_a1b2c3d4e5f6_add_granular_export_permissions.py index bf5aa790f784..37c207c99eed 100644 --- a/superset/migrations/versions/2026-03-02_12-00_a1b2c3d4e5f6_add_granular_export_permissions.py +++ b/superset/migrations/versions/2026-03-02_12-00_a1b2c3d4e5f6_add_granular_export_permissions.py @@ -66,11 +66,11 @@ def do_downgrade(session: Session) -> None: def upgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) def downgrade(): bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) diff --git a/superset/migrations/versions/2026-05-29_00-00_b4a3f2e1d0c9_fix_security_view_menu_case.py b/superset/migrations/versions/2026-05-29_00-00_b4a3f2e1d0c9_fix_security_view_menu_case.py index 9c728288607f..3502e6917653 100644 --- a/superset/migrations/versions/2026-05-29_00-00_b4a3f2e1d0c9_fix_security_view_menu_case.py +++ b/superset/migrations/versions/2026-05-29_00-00_b4a3f2e1d0c9_fix_security_view_menu_case.py @@ -115,7 +115,7 @@ def do_upgrade(session: Session) -> None: def upgrade() -> None: bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) diff --git a/superset/migrations/versions/2026-06-23_03-23_a7d3f1b9c2e4_cleanup_stale_can_import_pvm.py b/superset/migrations/versions/2026-06-23_03-23_a7d3f1b9c2e4_cleanup_stale_can_import_pvm.py index 6ab62c611cf1..b493593f8cd1 100644 --- a/superset/migrations/versions/2026-06-23_03-23_a7d3f1b9c2e4_cleanup_stale_can_import_pvm.py +++ b/superset/migrations/versions/2026-06-23_03-23_a7d3f1b9c2e4_cleanup_stale_can_import_pvm.py @@ -98,7 +98,7 @@ def do_downgrade(session: Session) -> None: def upgrade() -> None: bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_upgrade(session) try: session.commit() @@ -109,7 +109,7 @@ def upgrade() -> None: def downgrade() -> None: bind = op.get_bind() - session = Session(bind=bind, future=True) + session = Session(bind=bind) do_downgrade(session) try: session.commit() diff --git a/superset/migrations/versions/2026-06-30_00-00_d24e6b0a9c7f_strip_metricsqlexpressions_from_ag_grid_params.py b/superset/migrations/versions/2026-06-30_00-00_d24e6b0a9c7f_strip_metricsqlexpressions_from_ag_grid_params.py index 25428b141648..4e408132af1e 100644 --- a/superset/migrations/versions/2026-06-30_00-00_d24e6b0a9c7f_strip_metricsqlexpressions_from_ag_grid_params.py +++ b/superset/migrations/versions/2026-06-30_00-00_d24e6b0a9c7f_strip_metricsqlexpressions_from_ag_grid_params.py @@ -95,7 +95,7 @@ def _strip_query_context(slc: Slice) -> bool: def upgrade() -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) for slc in session.query(Slice).filter(Slice.viz_type == _VIZ_TYPE): _strip_params(slc) diff --git a/superset/migrations/versions/2026-08-05_00-00_1a27941d5352_restore_pivot_table_percent_display.py b/superset/migrations/versions/2026-08-05_00-00_1a27941d5352_restore_pivot_table_percent_display.py index a3757e8cd38d..c17dbb5cfbeb 100644 --- a/superset/migrations/versions/2026-08-05_00-00_1a27941d5352_restore_pivot_table_percent_display.py +++ b/superset/migrations/versions/2026-08-05_00-00_1a27941d5352_restore_pivot_table_percent_display.py @@ -156,7 +156,7 @@ def _migrate_query_context_form_data(slc: Slice) -> bool: def upgrade() -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) query = session.query(Slice).filter(Slice.viz_type == _VIZ_TYPE) for slc in paginated_update( diff --git a/superset/migrations/versions/2026-08-06_00-00_c4a1b8e2d739_databend_secure_to_sslmode.py b/superset/migrations/versions/2026-08-06_00-00_c4a1b8e2d739_databend_secure_to_sslmode.py index 34508611170e..31d70ec273dc 100644 --- a/superset/migrations/versions/2026-08-06_00-00_c4a1b8e2d739_databend_secure_to_sslmode.py +++ b/superset/migrations/versions/2026-08-06_00-00_c4a1b8e2d739_databend_secure_to_sslmode.py @@ -142,7 +142,7 @@ def _migrate( default: tuple[str, str] | None = None, ) -> None: bind = op.get_bind() - session = db.Session(bind=bind, future=True) + session = db.Session(bind=bind) query = session.query(Database).filter(Database.sqlalchemy_uri.like("databend%")) for database in paginated_update(query): diff --git a/superset/models/core.py b/superset/models/core.py index 7a4fad81d88c..a941fd52acd3 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -729,8 +729,6 @@ def _get_sqla_engine( # pylint: disable=too-many-locals # noqa: C901 if cached := _ENGINE_CACHE.get(cache_key): return cached try: - if "future" not in engine_kwargs: - engine_kwargs["future"] = True engine = create_engine(sqlalchemy_url, **engine_kwargs) except Exception as ex: raise self.db_engine_spec.get_dbapi_mapped_exception(ex) from ex diff --git a/superset/tags/models.py b/superset/tags/models.py index 39231b3e5a38..c60e660b23d6 100644 --- a/superset/tags/models.py +++ b/superset/tags/models.py @@ -49,7 +49,7 @@ from superset.models.slice import Slice from superset.models.sql_lab import Query -Session = sessionmaker(future=True) +Session = sessionmaker() user_favorite_tag_table = Table( "user_favorite_tag", diff --git a/tests/integration_tests/dao/conftest.py b/tests/integration_tests/dao/conftest.py index f34f9ea84262..3ada9cce64e3 100644 --- a/tests/integration_tests/dao/conftest.py +++ b/tests/integration_tests/dao/conftest.py @@ -80,11 +80,10 @@ def app_context(app: Flask) -> Generator[Session, None, None]: "sqlite:///:memory:", poolclass=StaticPool, connect_args={"check_same_thread": False}, - future=True, ) # Create session bound to in-memory database - session_factory = sessionmaker(bind=engine, future=True) + session_factory = sessionmaker(bind=engine) session = session_factory() # Make session compatible with Flask-SQLAlchemy expectations diff --git a/tests/integration_tests/fixtures/datasource.py b/tests/integration_tests/fixtures/datasource.py index 20cb8bf32ab7..071172b56faa 100644 --- a/tests/integration_tests/fixtures/datasource.py +++ b/tests/integration_tests/fixtures/datasource.py @@ -173,9 +173,7 @@ def get_datasource_post() -> dict[str, Any]: @pytest.fixture def load_dataset_with_columns() -> Generator[SqlaTable, None, None]: - engine = create_engine( - app.config["SQLALCHEMY_DATABASE_URI"], echo=True, future=True - ) + engine = create_engine(app.config["SQLALCHEMY_DATABASE_URI"], echo=True) meta = MetaData() students = Table( diff --git a/tests/integration_tests/migrations/composite_pk_association_tables__tests.py b/tests/integration_tests/migrations/composite_pk_association_tables__tests.py index 635b2c137948..b11090a27a11 100644 --- a/tests/integration_tests/migrations/composite_pk_association_tables__tests.py +++ b/tests/integration_tests/migrations/composite_pk_association_tables__tests.py @@ -55,7 +55,7 @@ def post_upgrade_engine() -> sa.engine.Engine: NULLs — with ``nullable=False`` here, ``test_fk_columns_not_null`` would pass trivially rather than because the migration promoted anything.""" - engine = sa.create_engine("sqlite:///:memory:", future=True) + engine = sa.create_engine("sqlite:///:memory:") md = sa.MetaData() for t in AFFECTED_TABLES: nullable = t.name in TABLES_WITH_NULLABLE_FKS diff --git a/tests/integration_tests/migrations/composite_pk_round_trip__tests.py b/tests/integration_tests/migrations/composite_pk_round_trip__tests.py index f4be94970dfd..d2ab5aa33b12 100644 --- a/tests/integration_tests/migrations/composite_pk_round_trip__tests.py +++ b/tests/integration_tests/migrations/composite_pk_round_trip__tests.py @@ -112,7 +112,7 @@ def test_round_trip_against_in_memory_sqlite() -> None: documented intentional asymmetry.) - Post-re-upgrade idempotency: shape matches the first post-upgrade. """ - engine = sa.create_engine("sqlite:///:memory:", future=True) + engine = sa.create_engine("sqlite:///:memory:") _build_pre_migration_schema(engine) _run_with_alembic_context(engine, _migration.upgrade) @@ -169,7 +169,7 @@ def test_upgrade_scrubs_null_fks_and_duplicates() -> None: the upgrade, and asserts exactly the distinct non-NULL pairs survive (the composite PK could not even be created otherwise). """ - engine = sa.create_engine("sqlite:///:memory:", future=True) + engine = sa.create_engine("sqlite:///:memory:") _build_pre_migration_schema(engine) md = sa.MetaData() diff --git a/tests/integration_tests/model_tests.py b/tests/integration_tests/model_tests.py index 5d25c9babcdb..ae978ff1e25d 100644 --- a/tests/integration_tests/model_tests.py +++ b/tests/integration_tests/model_tests.py @@ -151,7 +151,7 @@ def test_database_impersonate_user(self): SupersetTestCase.is_module_installed("pyhive"), "pyhive not installed" ) def test_impersonate_user_presto(self, mocked_create_engine): - mocked_create_engine.return_value = create_engine("sqlite://", future=True) + mocked_create_engine.return_value = create_engine("sqlite://") uri = "presto://localhost" principal_user = security_manager.find_user(username="gamma") extra = """ @@ -203,7 +203,7 @@ def test_impersonate_user_presto(self, mocked_create_engine): ) @mock.patch("superset.models.core.create_engine") def test_adjust_engine_params_mysql(self, mocked_create_engine): - mocked_create_engine.return_value = create_engine("sqlite://", future=True) + mocked_create_engine.return_value = create_engine("sqlite://") model = Database( database_name="test_database1", sqlalchemy_uri="mysql://user:password@localhost", @@ -236,7 +236,7 @@ def test_adjust_engine_params_mysql(self, mocked_create_engine): @mock.patch("superset.models.core.create_engine") def test_impersonate_user_trino(self, mocked_create_engine): - mocked_create_engine.return_value = create_engine("sqlite://", future=True) + mocked_create_engine.return_value = create_engine("sqlite://") principal_user = security_manager.find_user(username="gamma") with override_user(principal_user): @@ -277,7 +277,7 @@ def test_impersonate_user_trino(self, mocked_create_engine): SupersetTestCase.is_module_installed("thrift"), "thrift not installed" ) def test_impersonate_user_hive(self, mocked_create_engine): - mocked_create_engine.return_value = create_engine("sqlite://", future=True) + mocked_create_engine.return_value = create_engine("sqlite://") uri = "hive://localhost" principal_user = security_manager.find_user(username="gamma") extra = """ diff --git a/tests/unit_tests/charts/test_filters.py b/tests/unit_tests/charts/test_filters.py index 2eea5c0b08b1..112f7fab0a92 100644 --- a/tests/unit_tests/charts/test_filters.py +++ b/tests/unit_tests/charts/test_filters.py @@ -60,7 +60,7 @@ def _capture_filter(clause: object) -> MagicMock: compiled: str = str( captured["clause"].compile( - create_engine("sqlite://", future=True), + create_engine("sqlite://"), compile_kwargs={"literal_binds": True}, ) ) diff --git a/tests/unit_tests/common/test_query_context_factory.py b/tests/unit_tests/common/test_query_context_factory.py index c8b9c784e5bf..a8ef51d750df 100644 --- a/tests/unit_tests/common/test_query_context_factory.py +++ b/tests/unit_tests/common/test_query_context_factory.py @@ -332,8 +332,12 @@ def test_apply_granularity_with_x_axis_dict(self): self.factory._apply_granularity(query_object, form_data, datasource) + # Only the underlying expression is swapped to the overridden Time + # Column; the column keeps its original label so the offset join, the + # post-processing pivot and the frontend continue to reference it by the + # label the saved chart advertises (see SC-111332). assert query_object.columns[0]["sqlExpression"] == "P1D" - assert query_object.columns[0]["label"] == "P1D" + assert query_object.columns[0]["label"] == "ds" def test_apply_granularity_with_pivot_post_processing(self): """Test _apply_granularity with pivot post_processing""" diff --git a/tests/unit_tests/common/test_time_column_offset_repro.py b/tests/unit_tests/common/test_time_column_offset_repro.py new file mode 100755 index 000000000000..018be0791a14 --- /dev/null +++ b/tests/unit_tests/common/test_time_column_offset_repro.py @@ -0,0 +1,204 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Regression test for SC-111332. + +When a chart has a Time Comparison (time offset, e.g. ``1 year ago``) and the +Time Column driving the temporal x-axis is overridden on a dashboard to a +non-default column, the chart used to collapse into a single data point. + +Root cause: overriding the Time Column funnels through +``QueryContextFactory._apply_granularity`` (this is the single convergence point +for *both* dashboard entry points — the native "Time Column" filter and the +Display Controls "Time Column" dropdown; both emit ``granularity_sqla`` via +``extra_form_data``). That method used to rewrite the x-axis BASE_AXIS column's +``label`` to the overridden column name. The result dataframe was then keyed +under the *overridden* column name, but the offset join, the post-processing +pivot ``index`` and the frontend all look the x-axis up by the *original* saved +label. With a Time Comparison offset in play that desynchronization collapses +the series into a single point. + +The fix keeps the x-axis column's original label and only swaps the underlying +expression, so every consumer keeps referencing the same label. +""" + +from __future__ import annotations + +import sqlite3 +from typing import Any, cast + +import pandas as pd + +from superset.common.query_context_factory import QueryContextFactory +from superset.common.query_object import QueryObject +from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn +from superset.models.core import Database +from superset.superset_typing import Column + +X_AXIS_LABEL = "wedding_date" +OVERRIDE_COLUMN = "purchase_date" +OFFSET_METRIC = "sum_revenue__1 year ago" + + +def _make_dataset(db_path: str) -> SqlaTable: + """Build the reporter's dataset (monthly wedding/purchase dates).""" + uri = f"sqlite:///{db_path}" + + rows = [] + d = pd.Timestamp("2024-01-01") + while d <= pd.Timestamp("2026-04-01"): + rows.append( + { + "wedding_date": d.date().isoformat(), + # aligned but distinct from wedding_date + "purchase_date": (d + pd.Timedelta(days=14)).date().isoformat(), + "revenue": 100 + d.month * 10, + } + ) + d = d + pd.DateOffset(months=1) + + con = sqlite3.connect(db_path) + pd.DataFrame(rows).to_sql("weddings", con, index=False, if_exists="replace") + con.commit() + con.close() + + database = Database(database_name="repro_db", sqlalchemy_uri=uri) + table = SqlaTable(table_name="weddings", database=database) + table.columns = [ + TableColumn(column_name="wedding_date", is_dttm=True, type="DATETIME"), + TableColumn(column_name="purchase_date", is_dttm=True, type="DATETIME"), + TableColumn(column_name="revenue", type="INTEGER"), + ] + table.metrics = [ + SqlMetric(metric_name="sum_revenue", expression="SUM(revenue)"), + ] + return table + + +def _x_axis(col: str) -> dict[str, Any]: + return { + "label": col, + "sqlExpression": col, + "expressionType": "SQL", + "columnType": "BASE_AXIS", + "timeGrain": "P1M", + "isColumnReference": True, + } + + +def _pivot_post_processing() -> list[dict[str, Any]]: + """The pivot/flatten the frontend emits for a time-comparison line chart. + + The pivot ``index`` is keyed on the *saved* x-axis label, mirroring + ``timeComparePivotOperator``. + """ + return [ + { + "operation": "pivot", + "options": { + "index": [X_AXIS_LABEL], + "columns": [], + "drop_missing_columns": False, + "aggregates": { + "sum_revenue": {"operator": "mean"}, + OFFSET_METRIC: {"operator": "mean"}, + }, + }, + }, + {"operation": "flatten"}, + ] + + +def _build_query_object( + *, db_path: str, time_column_override: str | None +) -> QueryObject: + """Build the query object for a saved chart, optionally overriding the + Time Column the way a dashboard's ``extra_form_data`` (granularity_sqla) + does.""" + table = _make_dataset(db_path) + query_object = QueryObject( + datasource=table, + columns=cast("list[Column]", [_x_axis(X_AXIS_LABEL)]), + metrics=["sum_revenue"], + # A dashboard Time Column override sets granularity_sqla -> granularity. + granularity=time_column_override or X_AXIS_LABEL, + is_timeseries=False, + row_limit=10000, + time_offsets=["1 year ago"], + time_range="2025-01-01 : 2026-01-01", + from_dttm=pd.Timestamp("2025-01-01").to_pydatetime(), + to_dttm=pd.Timestamp("2026-01-01").to_pydatetime(), + filters=[ + { + "col": X_AXIS_LABEL, + "op": "TEMPORAL_RANGE", + "val": "2025-01-01 : 2026-01-01", + } + ], + post_processing=cast("list[dict[str, Any] | None]", _pivot_post_processing()), + extras={"time_grain_sqla": "P1M"}, + ) + if time_column_override: + # Both the native "Time Column" filter and the Display Controls dropdown + # converge here: extra_form_data.granularity_sqla -> granularity, then + # _apply_granularity re-points the x-axis at the overridden column. + QueryContextFactory()._apply_granularity( + query_object, {"x_axis": X_AXIS_LABEL}, table + ) + return query_object + + +def _run(query_object: QueryObject) -> pd.DataFrame: + # ``get_query_result`` already runs the offset join and post-processing + # (pivot/flatten), returning the production-shaped dataframe the chart + # consumes. + table = cast(SqlaTable, query_object.datasource) + return table.get_query_result(query_object).df + + +def test_default_time_column_plots_across_range(app_context, tmp_path): + """Sanity check: without an override the chart plots across the range.""" + db_path = str(tmp_path / "weddings.db") + df = _run(_build_query_object(db_path=db_path, time_column_override=None)) + assert X_AXIS_LABEL in df.columns + assert df[X_AXIS_LABEL].nunique() > 1 + assert OFFSET_METRIC in df.columns + + +def test_overridden_time_column_does_not_collapse(app_context, tmp_path): + """The reported bug: overriding the Time Column collapsed the chart into a + single point. After the fix the temporal x-axis is still returned under the + original label and plots across the full range with a populated offset.""" + db_path = str(tmp_path / "weddings.db") + df = _run( + _build_query_object(db_path=db_path, time_column_override=OVERRIDE_COLUMN) + ) + + # The frontend (and the offset join / pivot) look the x-axis up by the + # *original* saved label; it must not be renamed to the overridden column. + assert X_AXIS_LABEL in df.columns, ( + f"x-axis must stay under its original label; got {list(df.columns)}" + ) + assert OVERRIDE_COLUMN not in df.columns + + # Multiple points across the range instead of a single collapsed point. + assert df[X_AXIS_LABEL].nunique() > 1, "chart collapsed into a single point" + assert len(df) == 12 + + # The overridden column's data is what actually drives the series, and the + # time-comparison offset is populated (not all-NaN / single value). + assert OFFSET_METRIC in df.columns + assert df[OFFSET_METRIC].notna().sum() > 1 diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py index eee1ed15d9c5..16a35cb5eb4a 100644 --- a/tests/unit_tests/conftest.py +++ b/tests/unit_tests/conftest.py @@ -43,10 +43,10 @@ def get_session(mocker: MockerFixture) -> Callable[[], Session]: """ Create an in-memory SQLite db.session.to test models. """ - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") def get_session(): - Session_ = sessionmaker(bind=engine, future=True) # pylint: disable=invalid-name # noqa: N806 + Session_ = sessionmaker(bind=engine) # pylint: disable=invalid-name # noqa: N806 in_memory_session = Session_() # flask calls db.session.remove() diff --git a/tests/unit_tests/connectors/sqla/models_test.py b/tests/unit_tests/connectors/sqla/models_test.py index e95ff6c3d2e2..55c021a7c16d 100644 --- a/tests/unit_tests/connectors/sqla/models_test.py +++ b/tests/unit_tests/connectors/sqla/models_test.py @@ -277,7 +277,7 @@ def test_query_datasources_by_permissions(mocker: MockerFixture) -> None: """ db = mocker.patch("superset.connectors.sqla.models.db") - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") database = Database(database_name="my_db", id=1) sqla_table = SqlaTable( table_name="my_sqla_table", @@ -300,7 +300,7 @@ def test_query_datasources_by_permissions_with_catalog_schema( """ db = mocker.patch("superset.connectors.sqla.models.db") - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") database = Database(database_name="my_db", id=1) sqla_table = SqlaTable( table_name="my_sqla_table", @@ -954,7 +954,7 @@ def test_get_sqla_table_quoting_for_cross_catalog( from sqlalchemy import create_engine, select # Create a Postgres-like engine to test proper quoting - engine = create_engine("postgresql://user:pass@host/db", future=True) + engine = create_engine("postgresql://user:pass@host/db") # Mock database with cross-catalog support and proper quote_identifier database = mocker.MagicMock() @@ -991,7 +991,7 @@ def test_get_sqla_table_without_cross_catalog_ignores_catalog( from sqlalchemy import create_engine, select # Create a PostgreSQL engine (doesn't support cross-catalog queries) - engine = create_engine("postgresql://user:pass@localhost/db", future=True) + engine = create_engine("postgresql://user:pass@localhost/db") # Mock database without cross-catalog support database = mocker.MagicMock() @@ -1025,7 +1025,7 @@ def test_quoted_name_prevents_double_quoting(mocker: MockerFixture) -> None: """ from sqlalchemy import create_engine, select - engine = create_engine("postgresql://user:pass@host/db", future=True) + engine = create_engine("postgresql://user:pass@host/db") # Mock database database = mocker.MagicMock() diff --git a/tests/unit_tests/databases/error_provenance_test.py b/tests/unit_tests/databases/error_provenance_test.py index bacd7f00879a..0e00d2e33783 100644 --- a/tests/unit_tests/databases/error_provenance_test.py +++ b/tests/unit_tests/databases/error_provenance_test.py @@ -122,7 +122,7 @@ def test_raw_dbapi_cursor_error_is_outside_listener_scope( def test_unrelated_and_metadata_engine_errors_are_not_marked() -> None: assert not is_database_engine_error(ValueError("unrelated")) - metadata_engine = create_engine("sqlite://", future=True) + metadata_engine = create_engine("sqlite://") with ( metadata_engine.connect() as connection, pytest.raises(OperationalError) as exc_info, diff --git a/tests/unit_tests/databases/filters_test.py b/tests/unit_tests/databases/filters_test.py index 6a6cc6653462..9598ff9ff10b 100644 --- a/tests/unit_tests/databases/filters_test.py +++ b/tests/unit_tests/databases/filters_test.py @@ -63,8 +63,8 @@ def test_database_filter_full_db_access(mocker: MockerFixture) -> None: mocker.patch("flask.current_app.config", {"EXTRA_DYNAMIC_QUERY_FILTERS": False}) mocker.patch.object(security_manager, "can_access_all_databases", return_value=True) - engine = create_engine("sqlite://", future=True) - Session = sessionmaker(bind=engine, future=True) # noqa: N806 + engine = create_engine("sqlite://") + Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(Database) @@ -105,7 +105,7 @@ def test_database_filter(mocker: MockerFixture) -> None: ], ) - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(Database) diff --git a/tests/unit_tests/db_engine_specs/test_gsheets.py b/tests/unit_tests/db_engine_specs/test_gsheets.py index 2c996debd117..cb8dde47dc6c 100644 --- a/tests/unit_tests/db_engine_specs/test_gsheets.py +++ b/tests/unit_tests/db_engine_specs/test_gsheets.py @@ -225,7 +225,6 @@ def test_validate_parameters_catalog( } } }, - future=True, ) @@ -299,7 +298,6 @@ def test_validate_parameters_catalog_and_credentials( } } }, - future=True, ) diff --git a/tests/unit_tests/db_engine_specs/test_sqlite.py b/tests/unit_tests/db_engine_specs/test_sqlite.py index 6e47087befae..0efb6fdcbc89 100644 --- a/tests/unit_tests/db_engine_specs/test_sqlite.py +++ b/tests/unit_tests/db_engine_specs/test_sqlite.py @@ -120,7 +120,7 @@ def test_convert_dttm( def test_time_grain_expressions(dttm: str, grain: str, expected: str) -> None: # noqa: F811 from superset.db_engine_specs.sqlite import SqliteEngineSpec - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") with engine.begin() as connection: connection.execute(text("CREATE TABLE t (dttm DATETIME)")) connection.execute(text("INSERT INTO t VALUES (:dttm)"), {"dttm": dttm}) @@ -150,7 +150,7 @@ def test_year_pdf_time_grain(year: Optional[float], expected: Optional[str]) -> from superset.db_engine_specs.sqlite import SqliteEngineSpec - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") with engine.begin() as connection: connection.execute(text("CREATE TABLE t (year REAL)")) connection.execute(text("INSERT INTO t VALUES (:year)"), {"year": year}) diff --git a/tests/unit_tests/distributed_lock/distributed_lock_tests.py b/tests/unit_tests/distributed_lock/distributed_lock_tests.py index 4f9c7d9a0f3c..3b22c3adc43c 100644 --- a/tests/unit_tests/distributed_lock/distributed_lock_tests.py +++ b/tests/unit_tests/distributed_lock/distributed_lock_tests.py @@ -56,7 +56,7 @@ def _get_other_session() -> Session: from superset import db bind = db.session.get_bind() - SessionMaker = sessionmaker(bind=bind, future=True) # noqa: N806 + SessionMaker = sessionmaker(bind=bind) # noqa: N806 return SessionMaker() diff --git a/tests/unit_tests/extensions/test_sqlalchemy.py b/tests/unit_tests/extensions/test_sqlalchemy.py index 735dc701eb50..01ce1ced5fba 100644 --- a/tests/unit_tests/extensions/test_sqlalchemy.py +++ b/tests/unit_tests/extensions/test_sqlalchemy.py @@ -146,7 +146,7 @@ def test_superset(mocker: MockerFixture, app_context: None, table1: None) -> Non g.user.is_anonymous = False try: - engine = create_engine("superset://", future=True) + engine = create_engine("superset://") except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") @@ -187,7 +187,7 @@ def test_superset_limit(mocker: MockerFixture, app_context: None, table1: None) g.user.is_anonymous = False try: - engine = create_engine("superset://", future=True) + engine = create_engine("superset://") except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") @@ -222,7 +222,7 @@ def test_superset_joins( g.user.is_anonymous = False try: - engine = create_engine("superset://", future=True) + engine = create_engine("superset://") except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") @@ -266,7 +266,7 @@ def test_dml( g.user.is_anonymous = False try: - engine = create_engine("superset://", future=True) + engine = create_engine("superset://") except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") @@ -338,7 +338,7 @@ def test_security_manager( ) try: - engine = create_engine("superset://", future=True) + engine = create_engine("superset://") except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") @@ -372,7 +372,7 @@ def test_allowed_dbs(mocker: MockerFixture, app_context: None, table1: None) -> g.user.is_anonymous = False try: - engine = create_engine("superset://", allowed_dbs=["database1"], future=True) + engine = create_engine("superset://", allowed_dbs=["database1"]) except Exception as e: # Skip test if superset:// dialect can't be loaded (common in Docker) pytest.skip(f"Superset dialect not available: {e}") diff --git a/tests/unit_tests/migrations/composite_pk_association_tables_test.py b/tests/unit_tests/migrations/composite_pk_association_tables_test.py index 6b88977072cd..cc483a3bab11 100644 --- a/tests/unit_tests/migrations/composite_pk_association_tables_test.py +++ b/tests/unit_tests/migrations/composite_pk_association_tables_test.py @@ -103,7 +103,7 @@ def _build_in_memory_schema( primary_key=True, ), ) - engine = sa.create_engine("sqlite:///:memory:", future=True) + engine = sa.create_engine("sqlite:///:memory:") metadata.create_all(engine) # Seed parent rows so the FK constraints can be satisfied. # Identifiers come from the AFFECTED_TABLES test parameter list, not user input. diff --git a/tests/unit_tests/migrations/test_add_deleted_at_to_dashboards.py b/tests/unit_tests/migrations/test_add_deleted_at_to_dashboards.py index f4e65f989ed0..66dae1691774 100644 --- a/tests/unit_tests/migrations/test_add_deleted_at_to_dashboards.py +++ b/tests/unit_tests/migrations/test_add_deleted_at_to_dashboards.py @@ -76,7 +76,7 @@ def engine() -> Engine: on ``slug`` is included so SQLite's no-op branch can be asserted against the post-migration state. """ - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") md = MetaData() table = Table( TABLE_NAME, diff --git a/tests/unit_tests/migrations/test_add_deleted_at_to_slices.py b/tests/unit_tests/migrations/test_add_deleted_at_to_slices.py index af01fe1824c8..3510525dc6ef 100644 --- a/tests/unit_tests/migrations/test_add_deleted_at_to_slices.py +++ b/tests/unit_tests/migrations/test_add_deleted_at_to_slices.py @@ -64,7 +64,7 @@ def engine() -> Engine: ``deleted_at`` and its index, so only the columns that participate in the test are seeded. """ - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") md = MetaData() Table( TABLE_NAME, diff --git a/tests/unit_tests/migrations/test_add_deleted_at_to_tables.py b/tests/unit_tests/migrations/test_add_deleted_at_to_tables.py index 15d9615dc1f6..61719ea29764 100644 --- a/tests/unit_tests/migrations/test_add_deleted_at_to_tables.py +++ b/tests/unit_tests/migrations/test_add_deleted_at_to_tables.py @@ -64,7 +64,7 @@ def engine() -> Engine: ``deleted_at`` and its index, so only the columns that participate in the test are seeded. """ - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") md = MetaData() Table( TABLE_NAME, diff --git a/tests/unit_tests/migrations/test_databend_secure_to_sslmode.py b/tests/unit_tests/migrations/test_databend_secure_to_sslmode.py index b283ea6e779a..3e63557ac650 100644 --- a/tests/unit_tests/migrations/test_databend_secure_to_sslmode.py +++ b/tests/unit_tests/migrations/test_databend_secure_to_sslmode.py @@ -47,13 +47,13 @@ @pytest.fixture def engine(): - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") migration.Base.metadata.create_all(engine) return engine def _run(migrate, conn) -> None: - session = Session(bind=conn, future=True) + session = Session(bind=conn) with ( patch.object(migration, "op") as mock_op, patch.object(migration, "db") as mock_db, @@ -140,7 +140,7 @@ def test_rewrite_query_parameters_ignores_question_mark_in_credentials() -> None def test_upgrade_rewrites_only_databend_connections(engine) -> None: - with Session(engine, future=True) as seed: + with Session(engine) as seed: seed.add_all( [ Database( @@ -166,7 +166,7 @@ def test_upgrade_rewrites_only_databend_connections(engine) -> None: with engine.begin() as conn: _run(migration.upgrade, conn) - with Session(engine, future=True) as verify: + with Session(engine) as verify: assert ( verify.get(Database, 1).sqlalchemy_uri == f"databend://user:{MASK}@host:8000/db?sslmode=disable" @@ -186,7 +186,7 @@ def test_upgrade_rewrites_only_databend_connections(engine) -> None: def test_upgrade_is_idempotent(engine) -> None: - with Session(engine, future=True) as seed: + with Session(engine) as seed: seed.add( Database( id=1, sqlalchemy_uri=f"databend://user:{MASK}@host:8000/db?secure=false" @@ -198,7 +198,7 @@ def test_upgrade_is_idempotent(engine) -> None: with engine.begin() as conn: _run(migration.upgrade, conn) - with Session(engine, future=True) as verify: + with Session(engine) as verify: assert ( verify.get(Database, 1).sqlalchemy_uri == f"databend://user:{MASK}@host:8000/db?sslmode=disable" @@ -240,7 +240,7 @@ def test_downgrade_does_not_add_a_parameter(engine) -> None: def test_round_trip_through_upgrade_and_downgrade(engine) -> None: original = f"databend://user:{MASK}@host:8000/db?secure=false" - with Session(engine, future=True) as seed: + with Session(engine) as seed: seed.add(Database(id=1, sqlalchemy_uri=original)) seed.commit() @@ -249,5 +249,5 @@ def test_round_trip_through_upgrade_and_downgrade(engine) -> None: with engine.begin() as conn: _run(migration.downgrade, conn) - with Session(engine, future=True) as verify: + with Session(engine) as verify: assert verify.get(Database, 1).sqlalchemy_uri == original diff --git a/tests/unit_tests/migrations/test_enforce_oauth2_token_uniqueness.py b/tests/unit_tests/migrations/test_enforce_oauth2_token_uniqueness.py index bf1dfa320358..d63a3ca46c70 100644 --- a/tests/unit_tests/migrations/test_enforce_oauth2_token_uniqueness.py +++ b/tests/unit_tests/migrations/test_enforce_oauth2_token_uniqueness.py @@ -56,7 +56,7 @@ def engine() -> Engine: including duplicate (user_id, database_id) rows -- id 2 and id 3 both belong to user 1 + database 10, which the plain index never prevented. """ - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") md = MetaData() table = Table( TABLE_NAME, diff --git a/tests/unit_tests/migrations/test_restore_pivot_table_percent_display.py b/tests/unit_tests/migrations/test_restore_pivot_table_percent_display.py index d3c33183c71f..9d884a017c23 100644 --- a/tests/unit_tests/migrations/test_restore_pivot_table_percent_display.py +++ b/tests/unit_tests/migrations/test_restore_pivot_table_percent_display.py @@ -49,7 +49,7 @@ @pytest.fixture def engine(): - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") migration.Base.metadata.create_all(engine) return engine @@ -201,7 +201,7 @@ def test_migrate_query_context_noop_on_invalid_json(): def test_upgrade_restores_percent_display_only_for_affected_pivot_tables( engine, ) -> None: - with Session(engine, future=True) as seed: + with Session(engine) as seed: seed.add_all( [ # Had a fraction display configured before #41184 -- must be @@ -251,7 +251,7 @@ def test_upgrade_restores_percent_display_only_for_affected_pivot_tables( # bind the session to an explicit connection so paginated_update's # internal commits are visible once the outer transaction closes. with engine.begin() as conn: - upgrade_session = Session(bind=conn, future=True) + upgrade_session = Session(bind=conn) with ( patch.object(migration, "op") as mock_op, patch.object(migration, "db") as mock_db, @@ -260,7 +260,7 @@ def test_upgrade_restores_percent_display_only_for_affected_pivot_tables( mock_db.Session.return_value = upgrade_session migration.upgrade() - with Session(engine, future=True) as verify: + with Session(engine) as verify: slc1 = verify.get(Slice, 1) params1 = json.loads(slc1.params) assert params1[_NEW_FIELD] == "percent_total" diff --git a/tests/unit_tests/migrations/test_strip_metricsqlexpressions_from_ag_grid_params.py b/tests/unit_tests/migrations/test_strip_metricsqlexpressions_from_ag_grid_params.py index 3834f548a6a2..555d8cd3340b 100644 --- a/tests/unit_tests/migrations/test_strip_metricsqlexpressions_from_ag_grid_params.py +++ b/tests/unit_tests/migrations/test_strip_metricsqlexpressions_from_ag_grid_params.py @@ -73,7 +73,7 @@ def _contaminated_query_context() -> str: @pytest.fixture def engine(): - engine = create_engine("sqlite:///:memory:", future=True) + engine = create_engine("sqlite:///:memory:") migration.Base.metadata.create_all(engine) return engine @@ -146,7 +146,7 @@ def test_strip_query_context_noop_on_invalid_json() -> None: def test_upgrade_strips_both_fields(engine) -> None: """upgrade() must strip _FIELD from params and query_context for ag_grid_table slices, and must not touch slices of other viz types.""" - with Session(engine, future=True) as seed: + with Session(engine) as seed: seed.add_all( [ Slice( @@ -172,7 +172,7 @@ def test_upgrade_strips_both_fields(engine) -> None: # UPDATEs before the connection is committed; without it the outer commit # has nothing to write and the data is left unchanged. with engine.begin() as conn: - upgrade_session = Session(bind=conn, future=True) + upgrade_session = Session(bind=conn) with ( patch.object(migration, "op") as mock_op, patch.object(migration, "db") as mock_db, @@ -181,7 +181,7 @@ def test_upgrade_strips_both_fields(engine) -> None: mock_db.Session.return_value = upgrade_session migration.upgrade() - with Session(engine, future=True) as verify: + with Session(engine) as verify: slc1 = verify.get(Slice, 1) params1 = json.loads(slc1.params) assert _FIELD not in params1["extra_form_data"], ( diff --git a/tests/unit_tests/models/core_test.py b/tests/unit_tests/models/core_test.py index fe51e6c9f31d..a6f3034d0179 100644 --- a/tests/unit_tests/models/core_test.py +++ b/tests/unit_tests/models/core_test.py @@ -577,7 +577,7 @@ def test_get_sqla_engine(mocker: MockerFixture) -> None: create_engine_mock = mocker.patch( "superset.models.core.create_engine", - return_value=create_engine("sqlite://", future=True), + return_value=create_engine("sqlite://"), ) listen = mocker.spy(__import__("sqlalchemy").event, "listen") @@ -587,7 +587,6 @@ def test_get_sqla_engine(mocker: MockerFixture) -> None: create_engine_mock.assert_called_with( make_url("trino:///"), connect_args={"source": "Apache Superset"}, - future=True, ) listen.assert_any_call( create_engine_mock.return_value, @@ -622,7 +621,7 @@ def test_get_sqla_engine_caches_engine_per_url(mocker: MockerFixture) -> None: ) create_engine_mock = mocker.patch( "superset.models.core.create_engine", - return_value=create_engine("sqlite://", future=True), + return_value=create_engine("sqlite://"), ) listen = mocker.spy(__import__("sqlalchemy").event, "listen") @@ -662,7 +661,7 @@ def test_get_sqla_engine_does_not_cache_unsaved_instances( ) create_engine_mock = mocker.patch( "superset.models.core.create_engine", - return_value=create_engine("sqlite://", future=True), + return_value=create_engine("sqlite://"), ) listen = mocker.spy(__import__("sqlalchemy").event, "listen") @@ -736,7 +735,7 @@ def test_get_sqla_engine_user_impersonation(mocker: MockerFixture) -> None: create_engine_mock = mocker.patch( "superset.models.core.create_engine", - return_value=create_engine("sqlite://", future=True), + return_value=create_engine("sqlite://"), ) listen = mocker.spy(__import__("sqlalchemy").event, "listen") @@ -750,7 +749,6 @@ def test_get_sqla_engine_user_impersonation(mocker: MockerFixture) -> None: create_engine_mock.assert_called_with( make_url("trino:///"), connect_args={"user": "alice", "source": "Apache Superset"}, - future=True, ) listen.assert_any_call( create_engine_mock.return_value, @@ -801,7 +799,7 @@ def test_get_sqla_engine_user_impersonation_email(mocker: MockerFixture) -> None create_engine_mock = mocker.patch( "superset.models.core.create_engine", - return_value=create_engine("sqlite://", future=True), + return_value=create_engine("sqlite://"), ) listen = mocker.spy(__import__("sqlalchemy").event, "listen") @@ -815,7 +813,6 @@ def test_get_sqla_engine_user_impersonation_email(mocker: MockerFixture) -> None create_engine_mock.assert_called_with( make_url("trino:///"), connect_args={"user": "alice.doe", "source": "Apache Superset"}, - future=True, ) listen.assert_any_call( create_engine_mock.return_value, @@ -1333,7 +1330,7 @@ def test_get_schema_access_for_file_upload() -> None: try: from sqlalchemy import create_engine - create_engine("gsheets://", future=True) + create_engine("gsheets://") except Exception: pytest.skip("gsheets:// dialect not available (Shillelagh not installed)") @@ -2241,7 +2238,6 @@ def parking_creator() -> _ParkingSqliteConnection: def patched_create_engine(url: Any, **kwargs: Any) -> Any: kwargs["creator"] = parking_creator - kwargs["future"] = True return real_create_engine(url, **kwargs) mocker.patch( diff --git a/tests/unit_tests/models/helpers_test.py b/tests/unit_tests/models/helpers_test.py index a7156b795b96..e41b20313806 100644 --- a/tests/unit_tests/models/helpers_test.py +++ b/tests/unit_tests/models/helpers_test.py @@ -54,7 +54,6 @@ def database(mocker: MockerFixture, session: Session) -> Database: "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool, - future=True, ) database = Database(database_name="db", sqlalchemy_uri="sqlite://") @@ -126,7 +125,6 @@ def test_values_for_column_passes_catalog_and_schema( "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool, - future=True, ) database = Database(database_name="db", sqlalchemy_uri="sqlite://") @@ -187,7 +185,6 @@ def test_values_for_column_passes_none_catalog_and_schema( "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool, - future=True, ) database = Database(database_name="db", sqlalchemy_uri="sqlite://") diff --git a/tests/unit_tests/models/owner_association_tables_test.py b/tests/unit_tests/models/owner_association_tables_test.py index e979835f1555..081ff03d00b7 100644 --- a/tests/unit_tests/models/owner_association_tables_test.py +++ b/tests/unit_tests/models/owner_association_tables_test.py @@ -60,7 +60,7 @@ def _create_standalone(table: sa.Table) -> sa.engine.Engine: real ``Table`` object can be created without its parent tables while its primary-key constraint remains fully enforced. """ - engine = sa.create_engine("sqlite:///:memory:", future=True) + engine = sa.create_engine("sqlite:///:memory:") table.create(engine) return engine diff --git a/tests/unit_tests/security/exclude_users_filter_test.py b/tests/unit_tests/security/exclude_users_filter_test.py index 5091467c616a..ae516cf91fe5 100644 --- a/tests/unit_tests/security/exclude_users_filter_test.py +++ b/tests/unit_tests/security/exclude_users_filter_test.py @@ -44,8 +44,8 @@ def test_exclude_users_filter_no_exclusions(mocker: MockerFixture) -> None: mock_current_app, ) - engine = create_engine("sqlite://", future=True) - Session = sessionmaker(bind=engine, future=True) # noqa: N806 + engine = create_engine("sqlite://") + Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(User) @@ -70,7 +70,7 @@ def test_exclude_users_filter_with_config(mocker: MockerFixture) -> None: ) engine = create_engine("sqlite://") - Session = sessionmaker(bind=engine, future=True) # noqa: N806 + Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(User) @@ -106,7 +106,7 @@ def test_exclude_users_filter_with_security_manager(mocker: MockerFixture) -> No ) engine = create_engine("sqlite://") - Session = sessionmaker(bind=engine, future=True) # noqa: N806 + Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(User) @@ -144,7 +144,7 @@ def test_exclude_users_filter_config_takes_precedence(mocker: MockerFixture) -> ) engine = create_engine("sqlite://") - Session = sessionmaker(bind=engine, future=True) # noqa: N806 + Session = sessionmaker(bind=engine) # noqa: N806 session = Session() query = session.query(User) diff --git a/tests/unit_tests/utils/filters_test.py b/tests/unit_tests/utils/filters_test.py index d6360cc285f9..e718165b464b 100644 --- a/tests/unit_tests/utils/filters_test.py +++ b/tests/unit_tests/utils/filters_test.py @@ -51,7 +51,7 @@ def test_get_dataset_access_filters(mocker: MockerFixture) -> None: ) clause = get_dataset_access_filters(SqlaTable) - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") compiled_query = clause.compile(engine, compile_kwargs={"literal_binds": True}) assert str(compiled_query) == ( "dbs.id IN (1, 3) " @@ -116,7 +116,7 @@ def test_guest_embedded_dashboard_filter_uuid_resources( # structure (an EXISTS against embedded_dashboards.uuid) rather than the value. clause = guest_embedded_dashboard_filter() assert clause is not None - compiled = str(clause.compile(create_engine("sqlite://", future=True))) + compiled = str(clause.compile(create_engine("sqlite://"))) assert "EXISTS" in compiled assert "embedded_dashboards" in compiled assert "uuid" in compiled @@ -138,7 +138,7 @@ def test_guest_embedded_dashboard_filter_int_resources( assert clause is not None compiled = str( clause.compile( - create_engine("sqlite://", future=True), + create_engine("sqlite://"), compile_kwargs={"literal_binds": True}, ) ) @@ -165,7 +165,7 @@ def test_guest_embedded_dashboard_filter_mixed_uuid_and_int_ids( assert clause is not None # uuid column is BINARY(16), so compile without literal_binds and assert # structure: an EXISTS on embedded_dashboards OR a dashboards.id filter. - compiled = str(clause.compile(create_engine("sqlite://", future=True))) + compiled = str(clause.compile(create_engine("sqlite://"))) assert "embedded_dashboards" in compiled assert "dashboards.id IN" in compiled assert " OR " in compiled @@ -203,7 +203,7 @@ def test_guest_embedded_dashboard_filter_ignores_slug_in_mixed_token( clause = guest_embedded_dashboard_filter() assert clause is not None - compiled = str(clause.compile(create_engine("sqlite://", future=True))) + compiled = str(clause.compile(create_engine("sqlite://"))) assert "embedded_dashboards" in compiled assert "dashboards.id IN" in compiled assert "dashboards.slug" not in compiled diff --git a/tests/unit_tests/utils/pandas_sqlalchemy_compat_test.py b/tests/unit_tests/utils/pandas_sqlalchemy_compat_test.py index f81056dd8aba..980f31235460 100644 --- a/tests/unit_tests/utils/pandas_sqlalchemy_compat_test.py +++ b/tests/unit_tests/utils/pandas_sqlalchemy_compat_test.py @@ -35,7 +35,7 @@ def test_to_sql_accepts_sqlalchemy_engine_and_dtypes() -> None: """ restore_pandas_sqlalchemy_support() - engine = create_engine("sqlite://", future=True) + engine = create_engine("sqlite://") df = pd.DataFrame( { "name": ["a", "b"], diff --git a/tests/unit_tests/versioning/test_listener.py b/tests/unit_tests/versioning/test_listener.py index 2eeca0d36783..69e68c2473e1 100644 --- a/tests/unit_tests/versioning/test_listener.py +++ b/tests/unit_tests/versioning/test_listener.py @@ -41,9 +41,9 @@ class LifecycleRow(Base): @pytest.fixture def lifecycle_session() -> Iterator[Session]: """Yield an isolated SQLAlchemy session backed by in-memory SQLite.""" - engine = sa.create_engine("sqlite://", future=True) + engine = sa.create_engine("sqlite://") Base.metadata.create_all(engine) - session = sessionmaker(bind=engine, future=True)() + session = sessionmaker(bind=engine)() try: yield session finally: diff --git a/tests/unit_tests/views/test_soft_delete_filter.py b/tests/unit_tests/views/test_soft_delete_filter.py index 06e7312ab839..40d607b33c29 100644 --- a/tests/unit_tests/views/test_soft_delete_filter.py +++ b/tests/unit_tests/views/test_soft_delete_filter.py @@ -70,7 +70,7 @@ def query_with_session() -> MagicMock: """A MagicMock that quacks like a SQLAlchemy Query with a real Session whose ``info`` dict the filter can mutate.""" q = MagicMock() - real_session = Session(future=True) + real_session = Session() q.session = real_session return q