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

lint mode #8

Open
karupanerura opened this issue Jul 6, 2016 · 0 comments
Open

lint mode #8

karupanerura opened this issue Jul 6, 2016 · 0 comments
Assignees

Comments

@karupanerura
Copy link
Owner

karupanerura commented Jul 6, 2016

detect bad code and show warnings.

my $db = MyApp::DB->new(
   ...,
   lint => 1, # 0=ignored, 1=show warning, 2=throw exception
);

# (STDERR) You should specify `table_name` option at $file line $line.
$db->select_by_sql(q{
  SELECT
    user.*
  FROM
    user_item
      INNER JOIN user
        ON user.id = user_item.user_id
  WHERE
    user_item.item_id = 1
});

# (STDERR) Detected N+1 Problem, you should use `prefetch` option.
$db->txn_do(sub {
    my @user_item = $db->select(user_item => { item_id => 1 })->all;
    for my $user_item (@user_item) {
        my $user = $user_item->user; # or $db->select(user => { id => $user_item->user_id });
        # ...
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant