Skip to content

Commit b9f3570

Browse files
authored
do not set db_url to sqlite by default (#6347)
* do not set db_url to sqlite by default * fix tests * preserve rxconfig instead of recreating it
1 parent cc7436c commit b9f3570

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

packages/reflex-base/src/reflex_base/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class BaseConfig:
203203

204204
backend_host: str = "0.0.0.0"
205205

206-
db_url: str | None = "sqlite:///reflex.db"
206+
db_url: str | None = None
207207

208208
async_db_url: str | None = None
209209

reflex/utils/templates.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from reflex_base.config import get_config
1212

1313
from reflex.utils import console, net, path_ops, redir
14+
from reflex.utils.rename import rename_imports_and_app_name
1415

1516

1617
@dataclasses.dataclass(frozen=True)
@@ -175,7 +176,9 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str
175176
# the source code repo name on github.
176177
template_name = new_config.app_name
177178

178-
create_config(app_name)
179+
# Rewrite in place instead of regenerating from a stock template, so the
180+
# template's own config (db_url, redis_url, plugins, etc.) is preserved.
181+
rename_imports_and_app_name(constants.Config.FILE, template_name, app_name)
179182
initialize_app_directory(
180183
app_name,
181184
template_name=template_name,

tests/units/test_app.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,17 @@ def test_add_duplicate_page_route_error(app: App, first_page, second_page, route
377377
or not find_spec("pydantic"),
378378
reason="starlette_admin not installed or sqlmodel not installed or pydantic not installed",
379379
)
380-
def test_initialize_with_admin_dashboard(test_model: Model):
380+
def test_initialize_with_admin_dashboard(
381+
test_model: type[Model], mocker: MockerFixture
382+
):
381383
"""Test setting the admin dashboard of an app.
382384
383385
Args:
384386
test_model: The default model.
387+
mocker: pytest mocker object.
385388
"""
389+
conf = rx.Config(app_name="testing", db_url="sqlite:///reflex.db")
390+
mocker.patch("reflex_base.config._get_config", return_value=conf)
386391
app = App(admin_dash=AdminDash(models=[test_model]))
387392
assert app.admin_dash is not None
388393
assert len(app.admin_dash.models) > 0
@@ -425,17 +430,23 @@ def test_initialize_with_custom_admin_dashboard(
425430
or not find_spec("pydantic"),
426431
reason="starlette_admin not installed or sqlmodel not installed or pydantic not installed",
427432
)
428-
def test_initialize_admin_dashboard_with_view_overrides(test_model):
433+
def test_initialize_admin_dashboard_with_view_overrides(
434+
test_model: type[Model], mocker: MockerFixture
435+
):
429436
"""Test setting the admin dashboard of an app with view class overridden.
430437
431438
Args:
432439
test_model: The default model.
440+
mocker: pytest mocker object.
433441
"""
434442
from starlette_admin.contrib.sqla.view import ModelView
435443

436444
class TestModelView(ModelView):
437445
pass
438446

447+
conf = rx.Config(app_name="testing", db_url="sqlite:///reflex.db")
448+
mocker.patch("reflex_base.config._get_config", return_value=conf)
449+
439450
app = App(
440451
admin_dash=AdminDash(
441452
models=[test_model], view_overrides={test_model: TestModelView}

0 commit comments

Comments
 (0)