• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

statuscompliance / status-backend / 15132641868

20 May 2025 08:26AM UTC coverage: 53.287% (+0.4%) from 52.927%
15132641868

push

github

alvarobernal2412
test(scopes): added model

363 of 758 branches covered (47.89%)

Branch coverage included in aggregate %.

950 of 1706 relevant lines covered (55.69%)

8.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/controllers/query.controller.js
1
import { models } from '../models/models.js';
2
import { getSQLFromSequelize, parseSQLQuery } from '../utils/sqlQueryBuilder.js';
3
import { handleControllerError } from '../utils/errorHandler.js';
4

5
/**
6
 * Verifies if the specified model is supported
7
 * @param {string} modelName - Name of the model to verify
8
 * @returns {boolean} - true if the model is supported, false otherwise
9
 */
10
function isModelSupported(modelName) {
11
  return models && modelName && Object.hasOwn(models, modelName);
×
12
}
13

14
export async function createQuery(req, res) {
15
  const { model, operation, options } = req.body;
×
16
  
17
  try {
×
18
    if (!isModelSupported(model)) {
×
19
      return res.status(400).json({
×
20
        success: false,
21
        message: `Model not supported: ${model}`,
22
        supportedModels: Object.keys(models)
23
      });
24
    }
25
    
26
    const response = await getSQLFromSequelize(
×
27
      models[model],
28
      operation,
29
      options
30
    );
31
    return res.status(200).json({
×
32
      message: 'SQL query created successfully',
33
      query: response,
34
    });
35
  } catch (error) {
36
    return handleControllerError(res, error, 'Failed to create SQL query');
×
37
  }
38
}
39

40
export async function parseQuery(req, res) {
41
  try {
×
42
    const response = parseSQLQuery(req.body.rawSql);
×
43
    return res.status(200).json({
×
44
      message: 'SQL query parsed successfully',
45
      sql: response,
46
    });
47
  } catch (error) {
48
    return handleControllerError(res, error, 'Failed to parse SQL query');
×
49
  }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc