CodeSampleX

Exemple

sqlalchemy 2.0.51: exc.ObjectNotExecutableError

Échantillon vérifié pour pypi sqlalchemy 2.0.51: exc.ObjectNotExecutableError. Le contrat s'est exécuté sur python 3.12 · linux debian/x64 · docker et a…

sha256:92680a5c95b189a07ae79201f3c9fd65d1cb3d6240345053ac8e79c5cbda430a

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51
Paquets
Symboles
  • sqlalchemy.exc.ObjectNotExecutableError
Environnement
python
Créé
2026-09-05T23:38:29Z

Contrat

  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.

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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")

Seeder d'origine

anonyme