CodeSampleX

샘플

sqlalchemy 2.0.51: exc.ObjectNotExecutableError

검증된 샘플 — pypi sqlalchemy 2.0.51: exc.ObjectNotExecutableError. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:92680a5c95b189a07ae79201f3c9fd65d1cb3d6240345053ac8e79c5cbda430a

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 python linux 24 · ubuntu · glibc 2.39 x64 python python pip

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify sqlalchemy.exc.ObjectNotExecutableError in pkg:pypi/sqlalchemy@2.0.51
패키지
심벌
  • sqlalchemy.exc.ObjectNotExecutableError
환경
python
생성일
2026-09-05T23:38:29Z

컨트랙트

  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.

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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

오리진 시더

익명