Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not use schema when checking database entries on MS SQL #4542

Closed
gzres opened this issue Sep 27, 2017 · 1 comment
Closed

Can not use schema when checking database entries on MS SQL #4542

gzres opened this issue Sep 27, 2017 · 1 comment

Comments

@gzres
Copy link

@gzres gzres commented Sep 27, 2017

What are you trying to achieve?

I want to check data from table in different schema instead of default [dbo] using seeInDatabase

What do you get instead?

Error during executing SQL query.

If I use as table name: account.Note:

[PDOException] SQLSTATE[HY000]: General error: 208 Invalid object name 'account.Note'. [208] (severity 16) [(null)]

And when I provide table name with schema in this way: [account]. [Note]:

[PDOException] SQLSTATE[HY000]: General error: 102 Incorrect syntax near '='. [102] (severity 15) [(null)]

Example of using method:

$I->seeInDatabase('[account].[Note]', ['ID' => 1]);

Details

  • Codeception version: v2.3.5
  • PHP Version: 7.1.8
  • Operating System: ubuntu 16.04
  • Installation type: Composer
  • Suite configuration:
class_name: ApiTester
modules:
    enabled:
        - Asserts
        - \ApiHelper
        - REST:
            url: http://localhost:8074
            depends: PhpBrowser
        - Db:
            dsn: "dblib:host=xxx.xxx.xxx.xxx;dbname=xxxxxx;charset=utf8"
            user: xxxxxxx
            password: xxxxxxxxx
            dump: 'tests/resources/db/db-schema.sql'
            populate: true # run populator before all tests
@Naktibalda
Copy link
Member

@Naktibalda Naktibalda commented Sep 27, 2017

https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Lib/Driver/SqlSrv.php

getQuotedName method adds quotes around all identifiers, so you could try to use $I->seeInDatabase('account].[Note', ['ID' => 1]); as a workaround.

You are the first person to use Codeception with MSSQL in years, so you are welcome to improve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.