CodeSampleX

Beispiel

sqlalchemy 2.0.51: exc.ObjectNotExecutableError

Verifiziertes Beispiel für pypi sqlalchemy 2.0.51: exc.ObjectNotExecutableError. Der Vertrag lief auf python 3.12 · linux debian/x64 · docker und bestand.

sha256:92680a5c95b189a07ae79201f3c9fd65d1cb3d6240345053ac8e79c5cbda430a

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104…
2026-09-05

Fall

HOW
Ziel
verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51
Pakete
Symbole
  • sqlalchemy.exc.ObjectNotExecutableError
Umgebung
python
Erstellt
2026-09-05T23:38:29Z

Contract

  1. ObjectNotExecutableError inherits from ArgumentError and SQLAlchemyError and preserves the offending target object.
  2. ObjectNotExecutableError supports serialization and deserialization via standard pickle roundtrip.
  3. Connection.execute raises ObjectNotExecutableError when passed a raw SQL string or non-executable object.
  4. Connection.execute raises ObjectNotExecutableError when passed SQL schema elements like Table or Column that do not support direct execution.
  5. Connection.scalar and Connection.scalars raise ObjectNotExecutableError when passed a non-executable object.
  6. Wrapping raw SQL strings with sqlalchemy.text produces an executable construct that executes successfully.

Dateien

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# sqlalchemy ObjectNotExecutableError API

This sample pins `sqlalchemy` 2.0.51 and verifies `sqlalchemy.exc.ObjectNotExecutableError`.

In SQLAlchemy 2.0, direct execution of raw SQL strings and non-executable objects is prohibited; executable constructs such as `sqlalchemy.text()` must be used.

The contract verifies:
- `ObjectNotExecutableError` inherits from `ArgumentError` and `SQLAlchemyError` and preserves the offending target object.
- `ObjectNotExecutableError` supports serialization and deserialization via standard pickle roundtrip.
- `Connection.execute` raises `ObjectNotExecutableError` when passed a raw SQL string or non-executable object.
- `Connection.execute` raises `ObjectNotExecutableError` when passed SQL schema elements like `Table` or `Column` that do not support direct execution.
- `Connection.scalar` and `Connection.scalars` raise `ObjectNotExecutableError` when passed a non-executable object.
- Wrapping raw SQL strings with `sqlalchemy.text()` produces an executable construct that executes successfully.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/sqlalchemy@2.0.51
Demonstrate these symbols/APIs:
  - sqlalchemy.exc.ObjectNotExecutableError

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:d7a3a14145d3ee96a87dc92ea2b801e9cac4dc87b965be86d8b3d8541875ce48","contract":["ObjectNotExecutableError inherits from ArgumentError and SQLAlchemyError and preserves the offending target object.","ObjectNotExecutableError supports serialization and deserialization via standard pickle roundtrip.","Connection.execute raises ObjectNotExecutableError when passed a raw SQL string or non-executable object.","Connection.execute raises ObjectNotExecutableError when passed SQL schema elements like Table or Column that do not support direct execution.","Connection.scalar and Connection.scalars raise ObjectNotExecutableError when passed a non-executable object.","Wrapping raw SQL strings with sqlalchemy.text produces an executable construct that executes successfully."],"goal":"verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51","kind":"HOW","packages":["pkg:pypi/sqlalchemy@2.0.51"],"schemaVersion":1,"symbols":["sqlalchemy.exc.ObjectNotExecutableError"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/sqlalchemy@2.0.51"],"schemaVersion":1,"subject":"pkg:pypi/sqlalchemy@2.0.51","symbols":["sqlalchemy.exc.ObjectNotExecutableError"],"verifierAdapter":"python@1"}
requirements.txt
sqlalchemy==2.0.51
spec.json
{
  "schemaVersion": 1,
  "goal": "verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/sqlalchemy@2.0.51"
  ],
  "symbols": [
    "sqlalchemy.exc.ObjectNotExecutableError"
  ]
}
test/contract.py
import pickle
import sqlalchemy
from sqlalchemy import create_engine, text, Table, Column, Integer, MetaData
from sqlalchemy.exc import ObjectNotExecutableError, ArgumentError, SQLAlchemyError

# 1. Class hierarchy and direct instantiation
err = ObjectNotExecutableError("SELECT 1")
assert isinstance(err, ArgumentError), f"Expected ArgumentError, got {type(err)}"
assert isinstance(err, SQLAlchemyError), f"Expected SQLAlchemyError, got {type(err)}"
assert err.target == "SELECT 1"
assert "Not an executable object: 'SELECT 1'" in str(err)

# 2. Pickle / unpickle roundtrip support via __reduce__
dumped = pickle.dumps(err)
loaded = pickle.loads(dumped)
assert isinstance(loaded, ObjectNotExecutableError)
assert loaded.target == "SELECT 1"
assert str(loaded) == str(err)

# 3. Connection.execute raises ObjectNotExecutableError for non-executable targets
engine = create_engine("sqlite:///:memory:")

with engine.connect() as conn:
    # Raw SQL string
    try:
        conn.execute("SELECT 1")
        raise AssertionError("Expected ObjectNotExecutableError for raw string in conn.execute")
    except ObjectNotExecutableError as e:
        assert e.target == "SELECT 1"
        assert "Not an executable object" in str(e)

    # Non-clauseelement types (int, list, dict)
    for invalid_target in [123, [1, 2], {"key": "value"}]:
        try:
            conn.execute(invalid_target)
            raise AssertionError(f"Expected ObjectNotExecutableError for {invalid_target}")
        except ObjectNotExecutableError as e:
            assert e.target == invalid_target

    # ClauseElements that do not support direct execution (Table, Column)
    metadata = MetaData()
    test_table = Table("items", metadata, Column("id", Integer, primary_key=True))
    try:
        conn.execute(test_table)
        raise AssertionError("Expected ObjectNotExecutableError for Table object")
    except ObjectNotExecutableError as e:
        assert e.target is test_table

    try:
        conn.execute(test_table.c.id)
        raise AssertionError("Expected ObjectNotExecutableError for Column object")
    except ObjectNotExecutableError as e:
        assert e.target is test_table.c.id

    # 4. Connection.scalar and Connection.scalars raise ObjectNotExecutableError
    try:
        conn.scalar("SELECT 1")
        raise AssertionError("Expected ObjectNotExecutableError for raw string in conn.scalar")
    except ObjectNotExecutableError as e:
        assert e.target == "SELECT 1"

    try:
        conn.scalars("SELECT 1")
        raise AssertionError("Expected ObjectNotExecutableError for raw string in conn.scalars")
    except ObjectNotExecutableError as e:
        assert e.target == "SELECT 1"

    # 5. Wrapping raw SQL with text() creates an Executable and succeeds
    res_exec = conn.execute(text("SELECT 1")).scalar()
    assert res_exec == 1

    res_scalar = conn.scalar(text("SELECT 2"))
    assert res_scalar == 2

    res_scalars = conn.scalars(text("SELECT 3")).one()
    assert res_scalars == 3

print("CONTRACT PASS: sqlalchemy.exc.ObjectNotExecutableError verified offline")

Ursprungs-Seeder

anonym