MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_index_create

Method test_index_create

test/sql/test_constraints.py:606–646  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

604
605 @testing.provide_metadata
606 def test_index_create(self):
607 metadata = self.metadata
608
609 employees = Table(
610 "employees",
611 metadata,
612 Column("id", Integer, primary_key=True),
613 Column("first_name", String(30)),
614 Column("last_name", String(30)),
615 Column("email_address", String(30)),
616 )
617
618 i = Index(
619 "employee_name_index",
620 employees.c.last_name,
621 employees.c.first_name,
622 )
623 assert i in employees.indexes
624
625 i2 = Index(
626 "employee_email_index", employees.c.email_address, unique=True
627 )
628 assert i2 in employees.indexes
629
630 self.assert_sql_execution(
631 testing.db,
632 lambda: metadata.create_all(testing.db, checkfirst=False),
633 RegexSQL("^CREATE TABLE"),
634 AllOf(
635 CompiledSQL(
636 "CREATE INDEX employee_name_index ON "
637 "employees (last_name, first_name)",
638 [],
639 ),
640 CompiledSQL(
641 "CREATE UNIQUE INDEX employee_email_index ON "
642 "employees (email_address)",
643 [],
644 ),
645 ),
646 )
647
648 @testing.provide_metadata
649 def test_index_create_camelcase(self):

Callers

nothing calls this directly

Calls 9

TableClass · 0.90
ColumnClass · 0.90
StringClass · 0.90
IndexClass · 0.90
RegexSQLClass · 0.90
AllOfClass · 0.90
CompiledSQLClass · 0.90
assert_sql_executionMethod · 0.80
create_allMethod · 0.80

Tested by

no test coverage detected